Program received signal from GDB: EXC_BAD_ACCESS

Posted by user577185 on Stack Overflow See other posts from Stack Overflow or by user577185
Published on 2011-01-16T01:36:12Z Indexed on 2011/01/16 1:53 UTC
Read the original article Hit count: 384

Filed under:
|
|

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!

© Stack Overflow or respective owner

Related posts about osx

Related posts about error