Hi, Just wondering how to read a string I have written to this file, for verification that it was written to the file. If I do printf and read c string, it isn't verifying it was written to the file.
Code:
#include <stdio.h>
#define FILENAME "data.txt"
int main(void)
{
char rating[20]="Good";
FILE *data_1;
data_1 = fopen("data","w");
if(data_1==NULL)
printf("error Opening file");
else
{
fprintf(data_1,"%s", rating); /* writes the c string rating to file*/
}
/* don't know how to print what is in datafile to screen*/
fclose(data_1);
return 0;
}
Cheers