/* priklad pr8_16.c citanie zo suboru so zadanim nazvu suboru cez parametre
vytvoreneho ulohou pr8_15 */
#include <stdio.h>
#include <string.h>
#include <io.h>
#include <fcntl.h>
#include <sys/stat.h>
#define MAX 50
void main(int argc, char *argv[])
{
int in1,lng;
int pocet,min,max;
float x,y;
char line[MAX];
if (argc == 1) printf("Volanie: %s file1\n",argv[0]);
else if (argc > 2) printf("Volanie: %s file1\n",argv[0]);
else
{
if((in1=open(*++argv,O_RDONLY)) == -1)
{
perror("Error ");
printf("Can't open [%s]\n",*argv);
exit();
}
read(in1,&pocet,sizeof(pocet));
read(in1,&min,sizeof(min));
read(in1,&max,sizeof(max));
printf("Pocet = %d\n",pocet);
printf("Min = %d Max = %d\n",min,max);
for(lng=0;lng<pocet+1;lng++)
{
read(in1,&min,sizeof(int));
read(in1,line,min);
line[min]='\0';
printf("%d. %s",lng,line);
}
while((lng=read(in1,&x,sizeof(float)))>0)
{
read(in1,&y,sizeof(float));
printf("x,y: %f %f\n",x,y);
}
close(in1);
}
}