FANDOM


/* Lab 8b */
/* Kevin Duke and Tomi Babalola*/
#include <stdio.h>
#include <string.h>
 
void filecharacter(char file[])
{
 
  char status=0;
  int counter=0;
  /*initialize the string array*/
  char string[100];
  FILE *infilep;
 
  infilep = fopen(file, "r");
/*if file doesn't exist*/
  if(infilep==NULL)
    printf("Invalid file\n");
  else
  /*while it's not the end of file*/
    while(status != EOF)
      {
          /*print them in the string array*/
        status = fgetc(infilep);
        printf("%c", status);
        string[counter]=status;
        counter++;
      }
 
  return;
}
 
int main(void)
{
  char file[70];
 
  printf("Name of the file to print: ");
  gets(file);
  printf("\nThe file contents:\n");
  filecharacter(file);
 
  return 0;
}