Hi,
I am trying to create a file using fwrite. I am using VS2008 & Vista,
I CANT SEE THE FILE. k=1 printed. Can somebody plz help me to find out the problem why this file is not being created???Code:#include "stdafx.h" #include <stdio.h> #include <conio.h> struct lib{ char bname[30]; int id; float price; }; int _tmain(int argc, _TCHAR* argv[]) { FILE* fp; struct lib libVar; int k; fp=fopen("data.tmp", "wb+"); if(fp==NULL) printf("Error"); printf("Enter book name\n"); gets(libVar.bname); printf("Enter id\n"); scanf("%d", &libVar.id); printf("Enter price\n"); scanf("%f",&libVar.price); k=fwrite(&libVar,sizeof(libVar), 1, fp); printf("k=%d\n", k); fclose(fp); return 0; }
Zulfi.




Reply With Quote