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

void main(int argc, char *argv[])
{
  FILE *fp;
  char oneword[100];
  char *c;

  if(argc==1) printf("Volanie: %s filename\n",argv[0]);
  else
  {
    if(argc > 2)printf("Pozor! Spracuje sa iba 1. parameter!\n");
    fp = fopen(argv[1],"r");
    if (fp == NULL) printf("File [%s] doesn't exist\n",argv[1]);
    else
    {
      do
      {
        c = fgets(oneword,100,fp);  /* get one word from the file */
        if(c != NULL)
        printf("%s",oneword);     /* display it on the monitor */
      } while (c != NULL);  /* repeat until EOF (end of file) */
    }
    fclose(fp);
  }
}