/* priklad pr8_8.c citanie po slovach so zadanim nazvu suboru   */
#include "stdio.h"

void main(void)
{
  FILE *fp;
  char oneword[100],filename[25];
  char *c;

  printf("Enter filename: ");
  scanf("%s",filename);
  fp = fopen(filename,"r");
  if (fp == NULL) printf("File [%s] doesn't exist\n",filename);
  else
  {
    do
    {
      c = fgets(oneword,100,fp);  /* get one word from the file */
      if(c != NULL) printf("%s\n",oneword);     /* display it on the monitor */
    } while (c != NULL);  /* repeat until EOF (end of file) */
  }
  fclose(fp);
}