0
votes

FILE *fopen(const char *filename, const char *mode);

I saw that some people only put the name of the file inside the "filename" part, some others put the entire path

example

FILE *fopen("mytext.txt", r);

FILE *fopen("/myfolder/mytext.txt", r);

which is the correct one?

1
It depends on the OS. (that's the reason why the first argument is just a string) - wildplasser

1 Answers

2
votes

If the file is in current directory when you run the program - no.

If it's not - yes, you will need to specify the path (absolute or relative to current directory)