Dear friends, as evident from my last few posts, I am struggling with opening a file as buffer and write to it (guess it has *nothing* to do with gtk, but C. Still I will be grateful if you people kindly help). So, first, how to open file in buffer?
/* Files opened and edited directly*/ /* FILE *fop = fopen(filename, "a" ); if (!fop){ filename="Untitled.bib"; fop= fopen(filename,"a"); } */ /*Trying to open file as buffer and edit that*/ FILE *fopf = fopen(filename, "a" ); if (!fopf){ filename="Untitled.bib"; fopf= fopen(filename,"a"); } char fop[]="Hello World"; int buf_size= strlen(fop)+1; fwrite(fop,buf_size,1,fopf); if(!fop){ printf("failed"); } fclose(fopf); gtk_label_set_text(GTK_LABEL(flabel), filename); printf( fop, "@%s{%s,\n", strcombo, strkey ); if( strlen(strAuth)!=0) printf( fop, "\tAuthor=\"%s\",\n", strAuth); if( strlen(strEditor)!=0) printf( fop, "\tEditor=\"%s\",\n", strEditor); if( strlen(strTitle)!=0) printf( fop, "\tTitle=\"%s\",\n", strTitle); // fclose(fop); The very first part of the code (commented) used to access the file directly, an approach that I was advised against. So I tried to open the file in buffer. But this implementation makes the program crash as soon as enter some value. Please help _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list