I need to parse the file as an argument to my C code by using cat
:
cat filename | ./code -n 10
So that it works the same way as:
./code filename -n 10
Or is there any way to read the file directly through the cat
command by using read
syscall? I was thinking about something like this:
read([file from the cat], buf, sizeof(buf));
and maybe if I do it this way I don't need to do it like this:
fd = open(fileName, O_RDONLY);
read(fd, buf, sizeof(buf));
It s the first time I see cat
used this way; I tried to google it but couldn't find anything.
I am a beginner in C language and Unix; any help would be appreciated.
Thank you.