- May 8, 2005
- 415
- 0
- 76
I'm trying to make a program in c that will print the output from another program, along with some other stuff but I'm having trouble doing this
Basically, let's say I have a file test.txt which contains the text "hi"
and I have a program "abcd"
$cat test.txt | ./abcd
hi
$./abcd < test.txt
hi
More importantly, what I want is to store what was piped or sent to the C program in a string, which I can then do anything with (such as print it to stdout)
I cant seem to make this work. some of the things i've tried give me write error: Broken pipe
any suggestions on what the c syntax is?
Basically, let's say I have a file test.txt which contains the text "hi"
and I have a program "abcd"
$cat test.txt | ./abcd
hi
$./abcd < test.txt
hi
More importantly, what I want is to store what was piped or sent to the C program in a string, which I can then do anything with (such as print it to stdout)
I cant seem to make this work. some of the things i've tried give me write error: Broken pipe
any suggestions on what the c syntax is?