The following is my code to read a file.
Code:#include <stdio.h> #include <ctype.h> #include <string.h> main(int argc, char *argv[]) { FILE *cfPtr; char xyz[10]; if( argc != 2 ) { printf("Argument provided incorrect\n"); }else{ if((cfPtr = fopen(argv[1],"r")) == NULL){ printf("file couldnt not be open"); }else{ fscanf(cfPtr, "%s", xyz); while(!feof(cfPtr)){ printf("%s\n", xyz); fscanf(cfPtr, "%s", xyz); } fclose(cfPtr); } } }
The following is the file that i wanted to read.
My program manage to read the following content only. It comes out error msg after that. I tried to debug and it stateCode:#include <stdio.h> main(int argc, char *argv[]) { int c, i; if (argc == 1) /* No command line arguments */ while ((c = getchar()) != EOF) /* echo whatever is typed */ putchar(c); else /* at least one command line argument */ { printf("\n"); for(i = 0; i < argc; i++) printf("argv[%d]=\"%s\"\n", i, argv[i]); /* print each argument */ printf("\n"); /* NB argv[0] = program name */ } }
"00405410 mov dword ptr [edx+4],ecx". How can i solved this problem so that it is able to read till the end of the file ??
Code:#include <stdio.h> main(int argc, char *argv[]) { int c, i; if (argc == 1) /* No command line arguments */ while ((c = getchar()) != EOF) /* echo whatever is typed */ putchar(c); else /* at least one command line argument */ { printf("\n");



LinkBack URL
About LinkBacks


