Basically what you need to do is read the stdin
which is where the archive data will come from. A simplified implementation would be this:
#include <stdlib.h>
#include <stdio.h>
#define BUFF_SIZE 1024
int main(void) {
char buffer[BUFF_SIZE];
while (fgets(buffer, BUFF_SIZE, stdin) != NULL) {
printf("%s", buffer);
}
}
Behold working in the ideone. And in the repl it.. Also put on the Github for future reference.
So whatever comes through pipe operating system will be printed on the screen. The pipe will take a data source, may be a file but may be another source as well.
Thanks for the reply. I tested, but did not print anything. So I removed the
if
, I compiled and tried to run again but gives an error:Segmentation fault (core dumped)
– Lucas
I made a change, I had eaten ball, I could do something simpler. I still can’t guarantee that it’s okay because I have no way to test it here but if it doesn’t work out, tell me the problem that I try to solve.
– Maniero
Now it worked out! Thank you.
– Lucas