I was reading through Learn C on the Mac and I got up to a point which is dealing with files and I was looking through the first source code example, and when I run the example, it me one of the custom errors that the author put in, instead of reading the file. I am really stumped as to what is causing this, also, from what I've checked all of the other examples in the chapter (deals with files) report some form of error, in which it can't find the file. I was wondering if anyone could find as to what is wrong. I uploaded the project file if anyone wanted to take a look at it, along with main.c below.
Thanks,
John
Code:
Thanks,
John
Code:
Code:
#include <stdio.h>
int main (int argc, const char * argv[]) {
FILE *fp;
int c;
fp = fopen( "../../My Data File", "r" );
if ( NULL == fp ) {
printf( "Error opening ../My Data File" );
} else {
while ( (c = fgetc( fp )) != EOF )
putchar( c );
fclose( fp );
}
return 0;
}