Hi,
I am facing problem in inserting EOF character at the end of the binary file. I read CTRL+Z for windows but it doesn't work.
First of all I want to ask that does fclose(SOME FILE POINTER) not automatically insert EOF at the end of file????
Below is the approx. code that i am writing, Kindly tell me whether it is correct or is there a better way to put EOF:
Code:int add_Book() { fp = fopen("book.lib","a"); book bk; //Book Structure int add = 1; while(add == 1) { printf("Enter 1 for adding book and 2 to quit!!"); scanf("%d",&add); if(add==2) { Printf("Press CTRL+Z to quit!!!!"); scanf("%s%s",bk.author,bk.name); fwrite(&bk,sizeof(bk),1,fp); fclose(fp); } else if(add == 1) { printf("Enter the name of book "); scanf("%s",bk.name); printf("Enter the author "); scanf("%s",bk.author); fwrite(&bk,sizeof(bk),1,fp); fclose(fp); } }



2Likes
LinkBack URL
About LinkBacks



