Reputation: 225
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?
Upvotes: 1
Views: 626
Reputation: 7225
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)
Upvotes: 2