fscanf reads incorrect value ? -Xcode

I've placed File.rtf in the directory (library/Developer/Xcode/DerivedData/Test(projectname)/Build/Products/Debug ) and the code seems to open it but prints out the wrong output.The output is 1606422622 for any integer value in the file.

Going through the solutions of question similar to mine ,the answers were to get the input file in the right directory.I think I've done that but I just can't get the correct output.

Desperate for help.Thanks.

int main() {

int b;

    FILE *fp; fp=fopen("File.rtf","r");

      if(fp == NULL)

    { printf("File doesn't exist!\n");

  }

  fscanf(fp,"%i",&b);

   printf("%i\n",b);

   fclose(fp);

}

MacBook Pro

Posted on Apr 4, 2013 5:04 PM

Reply
5 replies

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

fscanf reads incorrect value ? -Xcode

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.