FILE *new = fopen("new.out", "w+"); // creates a new file that didnt exist before
char finput[50];
fprintf(new, "hello\nworld\n");
while(fgets(finput, 51, new) != NULL)
{ /*never reaches this point*/ }
What am I doing wrong? If I write to a file that doesn’t already exist, is it possible to read from that file later on?
You should
rewindorfseekbefore reading again. And please, don’t call a variablenew(because that is a C++ keyword).