Hi, I am just a beginners and I was studying my first book for learn C : "Learn C on the mac" by Dave Mark. It was very good until I arrived at the file chapter where my first project doesn't open the file ( in this case My Data File) and show me in the output all the printf (That should't appeare if main read my file) . I get stack with this project:
file://localhost/Users/matteotortora/Downloads/Learn%20C%20Projects%20(Xcode%204 -1.x)/10.01%20-%20printFile.zip
I wanna post the main.c directly so it easier for you to help me:
//
// main.c
// printFile
//
// Created by Dave Mark on 7/4/11.
// Copyright 2011 Dave Mark. All rights reserved.
//
#include
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\n\n" );
printf( "The file My Data File should be in the same folder as the project file.\n" );
printf( "The executable is buried within the DerivedData folder, five levels deep,\n" );
printf( "which is why there are five .. in the file path above.\n" );
printf( "To learn more about where Xcode builds your executables, go to Xcode\'s\n" );
printf( "Preferences and select the Locations tab.\n" );
} else {
while ( (c = fgetc( fp )) != EOF )
putchar( c );
fclose( fp );
}
return 0;
}
I know that there is already one post like mine but I din't find the right answer for me.
I will be really greatfull if you will help me because I would like finish my first book and I am preatty close to do that.
Thank you
0 comments:
Post a Comment