Home » Archimedes archive » Acorn User » AU 1995-07.adf » !Regulars_Regulars » C/c/RandomA

C/c/RandomA

This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.

Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.

Tape/disk: Home » Archimedes archive » Acorn User » AU 1995-07.adf » !Regulars_Regulars
Filename: C/c/RandomA
Read OK:
File size: 0B67 bytes
Load address: 0000
Exec address: 0000
File contents
/* C for Yourself - Acorn User July 1995
   Demonstration of random access file handling
   by Steve Mumford */

   #include <stdio.h>

void
main(void)
{
   FILE  *pointer;
   char  buffer[255];
   int   x, loop;

   printf("Random Access file handling\n");
   printf("---------------------------\n\n");
   printf("Creating file...\n\n");

   if ((pointer = fopen("<C$Dir>.datafile", "w")) == 0) {
   printf("File could not be opened for writing.\n");
   return;
   }

   printf("Please enter 5 strings of 15 characters or less:\n\n");
   printf("(Longer strings will be truncated)\n");

   for (loop = 1; loop <= 5; loop ++) {
      for (x = 0; x <= 15; x++) {
         buffer[x] = '\0';
      }

/* The above loop clears the string array by individually filling its first
   few elements with null bytes. */
   
      printf("Please enter string number %d:\n", loop);
      gets(buffer);

/* The user's string is copied into a large buffer - just in case they exceed
   their allowed length. */
   
      for (x = 0; x < 15; x++) {
         fputc(buffer[x], pointer);
      }

/* This loop copies the individual characters to the file, one by one. */

      fputc('\0', pointer); /* Finally, we make sure the string's terminated */
   }

/* Each record is precisely 16 bytes in length, so we're able to leap to the
   start of any particular one by multiplying its number by 16. */

   if (fclose(pointer) != 0) {
      printf("File could not be closed.\n");
   }

   printf("Reading file:\n");

   if ((pointer = fopen("<C$Dir>.datafile", "r")) == 0) {
      printf("File could not be opened for reading.\n");
      return;
   }
   do {
      do {
         printf("Please enter a number from 1 to 5 to see that record:\n");
         printf("(Enter 0 to leave the program)\n");
         scanf("%d",&x);
         while (getchar() != '\n'); /* This 'cleans' the input of scanf() */
         if (x == 0) break;
         if (x < 1 || x > 5) {
            printf("Sorry - that number was out of range.\n");
         }
      } while (x < 1 || x > 5);

/* The above do-while loop prompts the user for a number between one and five,
   and control will only leave the loop once a suitable number's been entered.
   There is a special condition; when x == 0, the loop is terminated and
   the load operation is skipped over. */

      if (x != 0) {
         if (fseek(pointer, (x-1) * 16, SEEK_SET) != 0) {
            printf("fseek() failed to change position.\n");
            return;
         }
      
         fgets(buffer, 17, pointer);

/* The above command loads up to 17-1 characters from the file given by
   'pointer' and puts them in 'buffer', writing a null byte at the end of
   the string. */

         puts(buffer);
         printf("\n");
      }
   } while (x != 0);

/* Last but not least, we close the file! */

   if (fclose(pointer) != 0) {
      printf("File could not be closed after reading.\n");
   }
}
00000000  2f 2a 20 43 20 66 6f 72  20 59 6f 75 72 73 65 6c  |/* C for Yoursel|
00000010  66 20 2d 20 41 63 6f 72  6e 20 55 73 65 72 20 4a  |f - Acorn User J|
00000020  75 6c 79 20 31 39 39 35  0a 20 20 20 44 65 6d 6f  |uly 1995.   Demo|
00000030  6e 73 74 72 61 74 69 6f  6e 20 6f 66 20 72 61 6e  |nstration of ran|
00000040  64 6f 6d 20 61 63 63 65  73 73 20 66 69 6c 65 20  |dom access file |
00000050  68 61 6e 64 6c 69 6e 67  0a 20 20 20 62 79 20 53  |handling.   by S|
00000060  74 65 76 65 20 4d 75 6d  66 6f 72 64 20 2a 2f 0a  |teve Mumford */.|
00000070  0a 20 20 20 23 69 6e 63  6c 75 64 65 20 3c 73 74  |.   #include <st|
00000080  64 69 6f 2e 68 3e 0a 0a  76 6f 69 64 0a 6d 61 69  |dio.h>..void.mai|
00000090  6e 28 76 6f 69 64 29 0a  7b 0a 20 20 20 46 49 4c  |n(void).{.   FIL|
000000a0  45 20 20 2a 70 6f 69 6e  74 65 72 3b 0a 20 20 20  |E  *pointer;.   |
000000b0  63 68 61 72 20 20 62 75  66 66 65 72 5b 32 35 35  |char  buffer[255|
000000c0  5d 3b 0a 20 20 20 69 6e  74 20 20 20 78 2c 20 6c  |];.   int   x, l|
000000d0  6f 6f 70 3b 0a 0a 20 20  20 70 72 69 6e 74 66 28  |oop;..   printf(|
000000e0  22 52 61 6e 64 6f 6d 20  41 63 63 65 73 73 20 66  |"Random Access f|
000000f0  69 6c 65 20 68 61 6e 64  6c 69 6e 67 5c 6e 22 29  |ile handling\n")|
00000100  3b 0a 20 20 20 70 72 69  6e 74 66 28 22 2d 2d 2d  |;.   printf("---|
00000110  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |----------------|
00000120  2d 2d 2d 2d 2d 2d 2d 2d  5c 6e 5c 6e 22 29 3b 0a  |--------\n\n");.|
00000130  20 20 20 70 72 69 6e 74  66 28 22 43 72 65 61 74  |   printf("Creat|
00000140  69 6e 67 20 66 69 6c 65  2e 2e 2e 5c 6e 5c 6e 22  |ing file...\n\n"|
00000150  29 3b 0a 0a 20 20 20 69  66 20 28 28 70 6f 69 6e  |);..   if ((poin|
00000160  74 65 72 20 3d 20 66 6f  70 65 6e 28 22 3c 43 24  |ter = fopen("<C$|
00000170  44 69 72 3e 2e 64 61 74  61 66 69 6c 65 22 2c 20  |Dir>.datafile", |
00000180  22 77 22 29 29 20 3d 3d  20 30 29 20 7b 0a 20 20  |"w")) == 0) {.  |
00000190  20 70 72 69 6e 74 66 28  22 46 69 6c 65 20 63 6f  | printf("File co|
000001a0  75 6c 64 20 6e 6f 74 20  62 65 20 6f 70 65 6e 65  |uld not be opene|
000001b0  64 20 66 6f 72 20 77 72  69 74 69 6e 67 2e 5c 6e  |d for writing.\n|
000001c0  22 29 3b 0a 20 20 20 72  65 74 75 72 6e 3b 0a 20  |");.   return;. |
000001d0  20 20 7d 0a 0a 20 20 20  70 72 69 6e 74 66 28 22  |  }..   printf("|
000001e0  50 6c 65 61 73 65 20 65  6e 74 65 72 20 35 20 73  |Please enter 5 s|
000001f0  74 72 69 6e 67 73 20 6f  66 20 31 35 20 63 68 61  |trings of 15 cha|
00000200  72 61 63 74 65 72 73 20  6f 72 20 6c 65 73 73 3a  |racters or less:|
00000210  5c 6e 5c 6e 22 29 3b 0a  20 20 20 70 72 69 6e 74  |\n\n");.   print|
00000220  66 28 22 28 4c 6f 6e 67  65 72 20 73 74 72 69 6e  |f("(Longer strin|
00000230  67 73 20 77 69 6c 6c 20  62 65 20 74 72 75 6e 63  |gs will be trunc|
00000240  61 74 65 64 29 5c 6e 22  29 3b 0a 0a 20 20 20 66  |ated)\n");..   f|
00000250  6f 72 20 28 6c 6f 6f 70  20 3d 20 31 3b 20 6c 6f  |or (loop = 1; lo|
00000260  6f 70 20 3c 3d 20 35 3b  20 6c 6f 6f 70 20 2b 2b  |op <= 5; loop ++|
00000270  29 20 7b 0a 20 20 20 20  20 20 66 6f 72 20 28 78  |) {.      for (x|
00000280  20 3d 20 30 3b 20 78 20  3c 3d 20 31 35 3b 20 78  | = 0; x <= 15; x|
00000290  2b 2b 29 20 7b 0a 20 20  20 20 20 20 20 20 20 62  |++) {.         b|
000002a0  75 66 66 65 72 5b 78 5d  20 3d 20 27 5c 30 27 3b  |uffer[x] = '\0';|
000002b0  0a 20 20 20 20 20 20 7d  0a 0a 2f 2a 20 54 68 65  |.      }../* The|
000002c0  20 61 62 6f 76 65 20 6c  6f 6f 70 20 63 6c 65 61  | above loop clea|
000002d0  72 73 20 74 68 65 20 73  74 72 69 6e 67 20 61 72  |rs the string ar|
000002e0  72 61 79 20 62 79 20 69  6e 64 69 76 69 64 75 61  |ray by individua|
000002f0  6c 6c 79 20 66 69 6c 6c  69 6e 67 20 69 74 73 20  |lly filling its |
00000300  66 69 72 73 74 0a 20 20  20 66 65 77 20 65 6c 65  |first.   few ele|
00000310  6d 65 6e 74 73 20 77 69  74 68 20 6e 75 6c 6c 20  |ments with null |
00000320  62 79 74 65 73 2e 20 2a  2f 0a 20 20 20 0a 20 20  |bytes. */.   .  |
00000330  20 20 20 20 70 72 69 6e  74 66 28 22 50 6c 65 61  |    printf("Plea|
00000340  73 65 20 65 6e 74 65 72  20 73 74 72 69 6e 67 20  |se enter string |
00000350  6e 75 6d 62 65 72 20 25  64 3a 5c 6e 22 2c 20 6c  |number %d:\n", l|
00000360  6f 6f 70 29 3b 0a 20 20  20 20 20 20 67 65 74 73  |oop);.      gets|
00000370  28 62 75 66 66 65 72 29  3b 0a 0a 2f 2a 20 54 68  |(buffer);../* Th|
00000380  65 20 75 73 65 72 27 73  20 73 74 72 69 6e 67 20  |e user's string |
00000390  69 73 20 63 6f 70 69 65  64 20 69 6e 74 6f 20 61  |is copied into a|
000003a0  20 6c 61 72 67 65 20 62  75 66 66 65 72 20 2d 20  | large buffer - |
000003b0  6a 75 73 74 20 69 6e 20  63 61 73 65 20 74 68 65  |just in case the|
000003c0  79 20 65 78 63 65 65 64  0a 20 20 20 74 68 65 69  |y exceed.   thei|
000003d0  72 20 61 6c 6c 6f 77 65  64 20 6c 65 6e 67 74 68  |r allowed length|
000003e0  2e 20 2a 2f 0a 20 20 20  0a 20 20 20 20 20 20 66  |. */.   .      f|
000003f0  6f 72 20 28 78 20 3d 20  30 3b 20 78 20 3c 20 31  |or (x = 0; x < 1|
00000400  35 3b 20 78 2b 2b 29 20  7b 0a 20 20 20 20 20 20  |5; x++) {.      |
00000410  20 20 20 66 70 75 74 63  28 62 75 66 66 65 72 5b  |   fputc(buffer[|
00000420  78 5d 2c 20 70 6f 69 6e  74 65 72 29 3b 0a 20 20  |x], pointer);.  |
00000430  20 20 20 20 7d 0a 0a 2f  2a 20 54 68 69 73 20 6c  |    }../* This l|
00000440  6f 6f 70 20 63 6f 70 69  65 73 20 74 68 65 20 69  |oop copies the i|
00000450  6e 64 69 76 69 64 75 61  6c 20 63 68 61 72 61 63  |ndividual charac|
00000460  74 65 72 73 20 74 6f 20  74 68 65 20 66 69 6c 65  |ters to the file|
00000470  2c 20 6f 6e 65 20 62 79  20 6f 6e 65 2e 20 2a 2f  |, one by one. */|
00000480  0a 0a 20 20 20 20 20 20  66 70 75 74 63 28 27 5c  |..      fputc('\|
00000490  30 27 2c 20 70 6f 69 6e  74 65 72 29 3b 20 2f 2a  |0', pointer); /*|
000004a0  20 46 69 6e 61 6c 6c 79  2c 20 77 65 20 6d 61 6b  | Finally, we mak|
000004b0  65 20 73 75 72 65 20 74  68 65 20 73 74 72 69 6e  |e sure the strin|
000004c0  67 27 73 20 74 65 72 6d  69 6e 61 74 65 64 20 2a  |g's terminated *|
000004d0  2f 0a 20 20 20 7d 0a 0a  2f 2a 20 45 61 63 68 20  |/.   }../* Each |
000004e0  72 65 63 6f 72 64 20 69  73 20 70 72 65 63 69 73  |record is precis|
000004f0  65 6c 79 20 31 36 20 62  79 74 65 73 20 69 6e 20  |ely 16 bytes in |
00000500  6c 65 6e 67 74 68 2c 20  73 6f 20 77 65 27 72 65  |length, so we're|
00000510  20 61 62 6c 65 20 74 6f  20 6c 65 61 70 20 74 6f  | able to leap to|
00000520  20 74 68 65 0a 20 20 20  73 74 61 72 74 20 6f 66  | the.   start of|
00000530  20 61 6e 79 20 70 61 72  74 69 63 75 6c 61 72 20  | any particular |
00000540  6f 6e 65 20 62 79 20 6d  75 6c 74 69 70 6c 79 69  |one by multiplyi|
00000550  6e 67 20 69 74 73 20 6e  75 6d 62 65 72 20 62 79  |ng its number by|
00000560  20 31 36 2e 20 2a 2f 0a  0a 20 20 20 69 66 20 28  | 16. */..   if (|
00000570  66 63 6c 6f 73 65 28 70  6f 69 6e 74 65 72 29 20  |fclose(pointer) |
00000580  21 3d 20 30 29 20 7b 0a  20 20 20 20 20 20 70 72  |!= 0) {.      pr|
00000590  69 6e 74 66 28 22 46 69  6c 65 20 63 6f 75 6c 64  |intf("File could|
000005a0  20 6e 6f 74 20 62 65 20  63 6c 6f 73 65 64 2e 5c  | not be closed.\|
000005b0  6e 22 29 3b 0a 20 20 20  7d 0a 0a 20 20 20 70 72  |n");.   }..   pr|
000005c0  69 6e 74 66 28 22 52 65  61 64 69 6e 67 20 66 69  |intf("Reading fi|
000005d0  6c 65 3a 5c 6e 22 29 3b  0a 0a 20 20 20 69 66 20  |le:\n");..   if |
000005e0  28 28 70 6f 69 6e 74 65  72 20 3d 20 66 6f 70 65  |((pointer = fope|
000005f0  6e 28 22 3c 43 24 44 69  72 3e 2e 64 61 74 61 66  |n("<C$Dir>.dataf|
00000600  69 6c 65 22 2c 20 22 72  22 29 29 20 3d 3d 20 30  |ile", "r")) == 0|
00000610  29 20 7b 0a 20 20 20 20  20 20 70 72 69 6e 74 66  |) {.      printf|
00000620  28 22 46 69 6c 65 20 63  6f 75 6c 64 20 6e 6f 74  |("File could not|
00000630  20 62 65 20 6f 70 65 6e  65 64 20 66 6f 72 20 72  | be opened for r|
00000640  65 61 64 69 6e 67 2e 5c  6e 22 29 3b 0a 20 20 20  |eading.\n");.   |
00000650  20 20 20 72 65 74 75 72  6e 3b 0a 20 20 20 7d 0a  |   return;.   }.|
00000660  20 20 20 64 6f 20 7b 0a  20 20 20 20 20 20 64 6f  |   do {.      do|
00000670  20 7b 0a 20 20 20 20 20  20 20 20 20 70 72 69 6e  | {.         prin|
00000680  74 66 28 22 50 6c 65 61  73 65 20 65 6e 74 65 72  |tf("Please enter|
00000690  20 61 20 6e 75 6d 62 65  72 20 66 72 6f 6d 20 31  | a number from 1|
000006a0  20 74 6f 20 35 20 74 6f  20 73 65 65 20 74 68 61  | to 5 to see tha|
000006b0  74 20 72 65 63 6f 72 64  3a 5c 6e 22 29 3b 0a 20  |t record:\n");. |
000006c0  20 20 20 20 20 20 20 20  70 72 69 6e 74 66 28 22  |        printf("|
000006d0  28 45 6e 74 65 72 20 30  20 74 6f 20 6c 65 61 76  |(Enter 0 to leav|
000006e0  65 20 74 68 65 20 70 72  6f 67 72 61 6d 29 5c 6e  |e the program)\n|
000006f0  22 29 3b 0a 20 20 20 20  20 20 20 20 20 73 63 61  |");.         sca|
00000700  6e 66 28 22 25 64 22 2c  26 78 29 3b 0a 20 20 20  |nf("%d",&x);.   |
00000710  20 20 20 20 20 20 77 68  69 6c 65 20 28 67 65 74  |      while (get|
00000720  63 68 61 72 28 29 20 21  3d 20 27 5c 6e 27 29 3b  |char() != '\n');|
00000730  20 2f 2a 20 54 68 69 73  20 27 63 6c 65 61 6e 73  | /* This 'cleans|
00000740  27 20 74 68 65 20 69 6e  70 75 74 20 6f 66 20 73  |' the input of s|
00000750  63 61 6e 66 28 29 20 2a  2f 0a 20 20 20 20 20 20  |canf() */.      |
00000760  20 20 20 69 66 20 28 78  20 3d 3d 20 30 29 20 62  |   if (x == 0) b|
00000770  72 65 61 6b 3b 0a 20 20  20 20 20 20 20 20 20 69  |reak;.         i|
00000780  66 20 28 78 20 3c 20 31  20 7c 7c 20 78 20 3e 20  |f (x < 1 || x > |
00000790  35 29 20 7b 0a 20 20 20  20 20 20 20 20 20 20 20  |5) {.           |
000007a0  20 70 72 69 6e 74 66 28  22 53 6f 72 72 79 20 2d  | printf("Sorry -|
000007b0  20 74 68 61 74 20 6e 75  6d 62 65 72 20 77 61 73  | that number was|
000007c0  20 6f 75 74 20 6f 66 20  72 61 6e 67 65 2e 5c 6e  | out of range.\n|
000007d0  22 29 3b 0a 20 20 20 20  20 20 20 20 20 7d 0a 20  |");.         }. |
000007e0  20 20 20 20 20 7d 20 77  68 69 6c 65 20 28 78 20  |     } while (x |
000007f0  3c 20 31 20 7c 7c 20 78  20 3e 20 35 29 3b 0a 0a  |< 1 || x > 5);..|
00000800  2f 2a 20 54 68 65 20 61  62 6f 76 65 20 64 6f 2d  |/* The above do-|
00000810  77 68 69 6c 65 20 6c 6f  6f 70 20 70 72 6f 6d 70  |while loop promp|
00000820  74 73 20 74 68 65 20 75  73 65 72 20 66 6f 72 20  |ts the user for |
00000830  61 20 6e 75 6d 62 65 72  20 62 65 74 77 65 65 6e  |a number between|
00000840  20 6f 6e 65 20 61 6e 64  20 66 69 76 65 2c 0a 20  | one and five,. |
00000850  20 20 61 6e 64 20 63 6f  6e 74 72 6f 6c 20 77 69  |  and control wi|
00000860  6c 6c 20 6f 6e 6c 79 20  6c 65 61 76 65 20 74 68  |ll only leave th|
00000870  65 20 6c 6f 6f 70 20 6f  6e 63 65 20 61 20 73 75  |e loop once a su|
00000880  69 74 61 62 6c 65 20 6e  75 6d 62 65 72 27 73 20  |itable number's |
00000890  62 65 65 6e 20 65 6e 74  65 72 65 64 2e 0a 20 20  |been entered..  |
000008a0  20 54 68 65 72 65 20 69  73 20 61 20 73 70 65 63  | There is a spec|
000008b0  69 61 6c 20 63 6f 6e 64  69 74 69 6f 6e 3b 20 77  |ial condition; w|
000008c0  68 65 6e 20 78 20 3d 3d  20 30 2c 20 74 68 65 20  |hen x == 0, the |
000008d0  6c 6f 6f 70 20 69 73 20  74 65 72 6d 69 6e 61 74  |loop is terminat|
000008e0  65 64 20 61 6e 64 0a 20  20 20 74 68 65 20 6c 6f  |ed and.   the lo|
000008f0  61 64 20 6f 70 65 72 61  74 69 6f 6e 20 69 73 20  |ad operation is |
00000900  73 6b 69 70 70 65 64 20  6f 76 65 72 2e 20 2a 2f  |skipped over. */|
00000910  0a 0a 20 20 20 20 20 20  69 66 20 28 78 20 21 3d  |..      if (x !=|
00000920  20 30 29 20 7b 0a 20 20  20 20 20 20 20 20 20 69  | 0) {.         i|
00000930  66 20 28 66 73 65 65 6b  28 70 6f 69 6e 74 65 72  |f (fseek(pointer|
00000940  2c 20 28 78 2d 31 29 20  2a 20 31 36 2c 20 53 45  |, (x-1) * 16, SE|
00000950  45 4b 5f 53 45 54 29 20  21 3d 20 30 29 20 7b 0a  |EK_SET) != 0) {.|
00000960  20 20 20 20 20 20 20 20  20 20 20 20 70 72 69 6e  |            prin|
00000970  74 66 28 22 66 73 65 65  6b 28 29 20 66 61 69 6c  |tf("fseek() fail|
00000980  65 64 20 74 6f 20 63 68  61 6e 67 65 20 70 6f 73  |ed to change pos|
00000990  69 74 69 6f 6e 2e 5c 6e  22 29 3b 0a 20 20 20 20  |ition.\n");.    |
000009a0  20 20 20 20 20 20 20 20  72 65 74 75 72 6e 3b 0a  |        return;.|
000009b0  20 20 20 20 20 20 20 20  20 7d 0a 20 20 20 20 20  |         }.     |
000009c0  20 0a 20 20 20 20 20 20  20 20 20 66 67 65 74 73  | .         fgets|
000009d0  28 62 75 66 66 65 72 2c  20 31 37 2c 20 70 6f 69  |(buffer, 17, poi|
000009e0  6e 74 65 72 29 3b 0a 0a  2f 2a 20 54 68 65 20 61  |nter);../* The a|
000009f0  62 6f 76 65 20 63 6f 6d  6d 61 6e 64 20 6c 6f 61  |bove command loa|
00000a00  64 73 20 75 70 20 74 6f  20 31 37 2d 31 20 63 68  |ds up to 17-1 ch|
00000a10  61 72 61 63 74 65 72 73  20 66 72 6f 6d 20 74 68  |aracters from th|
00000a20  65 20 66 69 6c 65 20 67  69 76 65 6e 20 62 79 0a  |e file given by.|
00000a30  20 20 20 27 70 6f 69 6e  74 65 72 27 20 61 6e 64  |   'pointer' and|
00000a40  20 70 75 74 73 20 74 68  65 6d 20 69 6e 20 27 62  | puts them in 'b|
00000a50  75 66 66 65 72 27 2c 20  77 72 69 74 69 6e 67 20  |uffer', writing |
00000a60  61 20 6e 75 6c 6c 20 62  79 74 65 20 61 74 20 74  |a null byte at t|
00000a70  68 65 20 65 6e 64 20 6f  66 0a 20 20 20 74 68 65  |he end of.   the|
00000a80  20 73 74 72 69 6e 67 2e  20 2a 2f 0a 0a 20 20 20  | string. */..   |
00000a90  20 20 20 20 20 20 70 75  74 73 28 62 75 66 66 65  |      puts(buffe|
00000aa0  72 29 3b 0a 20 20 20 20  20 20 20 20 20 70 72 69  |r);.         pri|
00000ab0  6e 74 66 28 22 5c 6e 22  29 3b 0a 20 20 20 20 20  |ntf("\n");.     |
00000ac0  20 7d 0a 20 20 20 7d 20  77 68 69 6c 65 20 28 78  | }.   } while (x|
00000ad0  20 21 3d 20 30 29 3b 0a  0a 2f 2a 20 4c 61 73 74  | != 0);../* Last|
00000ae0  20 62 75 74 20 6e 6f 74  20 6c 65 61 73 74 2c 20  | but not least, |
00000af0  77 65 20 63 6c 6f 73 65  20 74 68 65 20 66 69 6c  |we close the fil|
00000b00  65 21 20 2a 2f 0a 0a 20  20 20 69 66 20 28 66 63  |e! */..   if (fc|
00000b10  6c 6f 73 65 28 70 6f 69  6e 74 65 72 29 20 21 3d  |lose(pointer) !=|
00000b20  20 30 29 20 7b 0a 20 20  20 20 20 20 70 72 69 6e  | 0) {.      prin|
00000b30  74 66 28 22 46 69 6c 65  20 63 6f 75 6c 64 20 6e  |tf("File could n|
00000b40  6f 74 20 62 65 20 63 6c  6f 73 65 64 20 61 66 74  |ot be closed aft|
00000b50  65 72 20 72 65 61 64 69  6e 67 2e 5c 6e 22 29 3b  |er reading.\n");|
00000b60  0a 20 20 20 7d 0a 7d                              |.   }.}|
00000b67