I wrote the following code:
void WriteToFile(const char** strings, const char* path, int n)
{
FILE* fp = fopen(path, "w");
int i;
if(fp)
{
for(i = 0 ; i < n ; i++)
{
puts(strings[i]);
fprintf(fp, "%s\n", strings[i]);
}
}
else
{
printf("Error at writing to file.\n");
exit(1);
}
fclose(fp);
}
I get an error - fp is pointing to NULL - means fopen()
didn't work, weird, I printed the path too and it has no \n
or something weird in it and it's available in my computer.