So I have this function that goes as follows f(char * str)
. The string argument is a file name that is accessed using another function. So if I do f("grille1.txt")
the program works as expected. However, if I do
char * filename;
scanf("%s", filename);
f(filename);
the program doesn't work as expected. So I concluded that the issue is with the scanf
. However I tried doing
printf("%d Are they equal?", !strcmp(filename, "grille1.txt"));
and I get a 1 as a result which means that they are indeed equal so what could the issue be that results in using the variable filename
not giving the same results as manually using "grille1.txt"
?