problem with fopen and absolute path
Hi every one
i have a problem with relatives path to files when i try to open a file in c.
Below will follow the code taken from a bigger program
Code:
FILE *infil;
char filname[100] = "C:\\temp\\testdata\\";
strcat(filname, readme.txt);
printf("%s \n", filname);
infil = fopen(filname, "rb"); // tested also with only r
if (infil== NULL)
{
printf("Error: can't open infile.\n");
}
Why is infil null. The path is correcte and i can see also when when i copy and paste from printf("%s \n", filname) . By the way you need to have \\ in the path above because C\... with only one \ doesn't work so the error is not there. Some research with google didn't approach me to the solution so i hope therefore that some of you can answer on this question