R
Rudra Banerjee
Dear friends,
I have a function,
static void mk_bib(GtkWidget *widget, gpointer data) {
if (!filename) {
caution("No File Selected");
} else {
char *bibstyl = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(bibcombo));
if (strcmp(bibstyl, "==select bibstyle==") == 0) {
caution("Select Bibliography style file");
} else {
char *p1 = filename;
char *p2 = rindex(p1, '.');
if (p2 != NULL) {
if (strcmp(p2, ".bib") == 0) {
*p2 = '\0';
}
}
g_print("Before basefn=Bibstyl=>%s\n",bibstyl);
char *basefn=bibstyl;
strcat(basefn, ".tex");
g_print("Before basefn=Bibstyl=>%s\n",bibstyl);
}
}
}
which, while running, changes value of bibstyl after strcat.
the result of two g_print is:
Before basefn=Bibstyl=>aabbrv
Before basefn=Bibstyl=>aabbrv.tex
Why it is so? Where I am doing wrong?
I have a function,
static void mk_bib(GtkWidget *widget, gpointer data) {
if (!filename) {
caution("No File Selected");
} else {
char *bibstyl = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(bibcombo));
if (strcmp(bibstyl, "==select bibstyle==") == 0) {
caution("Select Bibliography style file");
} else {
char *p1 = filename;
char *p2 = rindex(p1, '.');
if (p2 != NULL) {
if (strcmp(p2, ".bib") == 0) {
*p2 = '\0';
}
}
g_print("Before basefn=Bibstyl=>%s\n",bibstyl);
char *basefn=bibstyl;
strcat(basefn, ".tex");
g_print("Before basefn=Bibstyl=>%s\n",bibstyl);
}
}
}
which, while running, changes value of bibstyl after strcat.
the result of two g_print is:
Before basefn=Bibstyl=>aabbrv
Before basefn=Bibstyl=>aabbrv.tex
Why it is so? Where I am doing wrong?