I have written a code to create a file and store 3 records each record has a string and a number.
My code successfully creates the file but i cannot read and display its contents.
Please tell me where i went wrong?
int n; //number declaration
char a; //string declaration
fptr=fopen("myfile.txt","w"); //opening file
if(fptr==NULL) printf("Error opening file!"); //error
for(n=1;n<=3;n++) //loop for writing to file
fclose(fptr); //closing file
fptr=fopen("myfile.txt","r"); //opening in reading mode
printf("%s %d\n",a,n); //display