/* priklad pr8_11.c cislovanie riadkov so zadanim nazvu suboru cez parametre*/
#include "stdio.h"
#define MAX 80

void main(int argc, char *argv[])
{
  FILE *fp;
  char line[MAX];
  int ln;

  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,"r");
    if (fp == NULL)
    {
      printf("Can't open [%s]\n",*argv);
      exit();
    }
    else
    {
      ln=0;
      while (fgets(line,MAX,fp))  /* get one line from the file */
      printf("%3d : %s",++ln,line);
      fclose(fp);
    }
  }
}