The function fopen(FILE *fp)
in XCode it's not working, I put the text file in the root directory, but not work, it's weird because, executing from terminal works fine, but executing from IDE not.
The sintax that I use it's this:
FILE *fp=fopen("name.txt", "r");
if(fp==NULL)
{
printf("the text file can't be opened");
exit(0);
}
else
return fp;
And always return NULL
.
well what's the working directory when run via xcode?
by default IIRC it isnt set and that might be the difference between IDE and terminal.
-- set the working dir:
go to: product > scheme > edit scheme...
there go to:
options tab and choose a working directory
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With