I am using
FILE *fp = fopen("pasta/test.txt",w);
but this line doesn´t create a file in folder "pasta", i am creating a file with name "pasta/test.txt", can you help me?
I am using
FILE *fp = fopen("pasta/test.txt",w);
but this line doesn´t create a file in folder "pasta", i am creating a file with name "pasta/test.txt", can you help me?
The answer is in this question here (it is not a duplicate) the distribution you are using is irrelevant, since those are POSIX calls. Google them, is good to know them
You need to check the return value of fopen
and use errno
. The perror
function is quite useful:
FILE *fp = fopen("/pasta/test.txt", "w");
if (fp == NULL) {
perror("Opening file failed:");
}