Program received signal from GDB: EXC_BAD_ACCESS
- by user577185
Well, I'm starting development on the Mac OS X this code that you'll see is in a book that I bought, really basic like Chapter 3. And I can't run it. PLEASE HELP ME:
C301.m :
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[]) {
if (argc == 1) {
NSLog (@"You need to provide a file name");
return -1;
}
FILE *wordFile = fopen("tmp/words.txt", "r");
char word[100];
while (fgets(word, 100, wordFile)) {
word[strlen(word) - 1] = '\0';
NSLog(@"%s is %d characters long", word, strlen(word));
}
fclose(wordFile);
return 0;
} //main
The file is in its place.
Thank you so much!