When I call the function fopen to create or read a file in a specific directory, it does not work.
If I call the function to read or create the file in the root project, it works very well.
This is my folder structure:
|--project/
|--main.c
|--files/
if I call the function in this way:
FILE *file;
file = fopen("project/files/test.txt", "w");
It does not work. The function cannot create the file;
But if i call in this whay, it works:
FILE *file;
file = fopen("test.txt", "w");
Whay? And how can I do this?
fopendoes not create directories.Your directory structure is:
"files"files in not a subdirectory of the"project"directory(I assume that the program is run from the
rootdirectory)