Reputation: 1559
I need to pipe 3 programs: AddWith5.c AddWith2.c MultiplyWith3.c
My code follows this pattern:
int main(){
int x;
scanf("%i",&x);
printf("%i",x*3);
return 0;
}
I need to pipe them so that I get the output for: ((x+5)+2)*3
(f1.txt contains the number 2)
Can someone help me?
I tried: AddWith5.c | AddWith2.c | MultiplyWith3.c < f1.txt > f2.txt
Thank you in advance!
Upvotes: 0
Views: 121
Reputation: 399871
Pipes are read left to right, so the input must be given to the "head" (the leftmost) program in the pipe:
$ AddWith5 < f1.txt | AddWith2 | MultiplyWith3
Also, you don't invoke C files directly, each file needs to be individually compiled into a binary with the above names, first.
This has, by the way, nothing to do with C. The programs could just as well be shell scripts, or written in any other programming language, it doesn't matter at this level.
Upvotes: 1