FILE * f = fopen("c:\\out.txt", "wb"); if(f == NULL) printf("ERR"); This code prints ERR. c:\out.txt does not yet exist. However if I create an empty file called out.txt and then place in the c:\ the code executes fine. How do I make c create a file if it does not exist?
w+instead ofwb. you could also try calling fclose. at the end of the program.errnowhenfopenfails to determine what the problem is..\\out.txtfor example.