/* mcPj004E2.c */ /* Real World Application of "fileReader.c" << (mcPj004E1.c) */ /* From old days, here is a note of progress. -- History note -- * mcPj004A.c << Sample 10.04 * mcPj004B.c << Example fscanf(), Screen access. * mcPj004C.c My first successful FileAccess. One word only. * It seems for me a compiling set of libraries were crucial. * OR, in PC's C, I didn't need #include, and * this could be the reason. * mcPj004D.c My second successful FileAccess. One line only. * mcPj004E.c This one, my third successful FileAccess. Whole text. */ /* (2004-12-23) One page of explanation fits about 23 lines or around. * Since no , nor "clrscr()", I had to deal with "Form Feed" * mechanism to roll up the screen. Used fix blank lines * So, this naration display is designed for about 23 lines each. * This is a combination of Text-read (printf()) on Screen, and * waiting a user's input (scanf()) as I did in PC C-codes. * It works well. */ #include <stdio.h> #include <stdlib.h> #include <string.h> int main(void) { FILE *fp; char line[256], uType[8]; int i; *line=0; i=0; fp=fopen("1_Ref", "r"); /* Read all lines from the file stream pointing to "Ref.txt" */ /* from i=0 to i=22 */ do{ printf("%s", line); i++; }while( (fgets(line, 256, fp))!=NULL && i<=22 ); printf("Type any key then [return] : "); scanf( "%s", &uType); /* from i=23 to i=45 */ printf("\n"); do{ printf("%s", line); i++; }while( (fgets(line, 256, fp))!=NULL && i<=45 ); /* plus 23 */ printf("Type any key then [return] : "); scanf( "%s", &uType); /* from i=46 to i=68 */ printf("\n"); do{ printf("%s", line); i++; }while( (fgets(line, 256, fp))!=NULL && i<=68 ); /* plus 23 */ printf("END of \"1_Get_MPW_first\". "); /* scanf( "%s", &uType); */ /* from i=69 to i=91 * printf("\n"); * do{ * printf("%s", line); * i++; * }while( (fgets(line, 256, fp))!=NULL && i<=91 ); * printf("Type any key then [return] : "); * scanf( "%s", &uType); */ fclose(fp); return 0; }