First of all, this is my fist stack overflow question, so forgive me if I format this wrong.
I am a beginner at C, and I am up to a point in my book on File i/o. The following code, which is supposed to print the lines to test.txt, doesn't create a new txt file or... do anything.
I am running Code Blocks 16.01 on Windows. Is this code designed for another OS?
#include <stdio.h>
#include <stdlib.h>
main() {
FILE *fp;
fp = fopen("/tmp/test.txt", "w+");
fprintf(fp, "This is testing for fprintf...\n");
fputs("This is testing for fputs...\n", fp);
fclose(fp);
}
Ok, so removing the slash makes it work. In the original code, it is 'fopen("/tmp/test.txt", "W+");' Shouldn't this create the file in folder tmp?