I need help writing to a file. I can't get it to work but its not giving any errors.
There is no compile error, there is a segmentation fault, but that occurs later in the code. I have print statements that get printed before the segmentation fault. After i run the code, the message "Got Here" does not get printed to output.txt. I also open another stream for writing later in the code, but it is after all this happens, and it does not work either. Any help is appreciated.
#define OUTPUT "output.txt"
out = fopen(OUTPUT, "w");
if(!out) fatal("Could not open %s for writing\n", OUTPUT);
fprintf(out, "Got Here");