Question: //pipe1.cpp #include #include #include #include #include using namespace std; int main() { FILE *fpi; //for reading a pipe char buffer[BUFSIZ+1]; //BUFSIZ defined in int chars_read;
//pipe1.cpp #include |
What do you see when you execute "pipe1" ? Why? Modify the program pipe1.cpp to pipe1a.cpp so that it accepts a command (e.g. "ls -l") from the keyboard. For example, when you execute "./pipe1a ps -auxw", it should give you the same output as pipe1.cpp. (Hint: Use string functions strcpy() and strcat() to store the commands in a buffer. Your main function should be like: int main( int argc, char *argv[] ) )
You can also send output to an external program via a pipe. Try the following program:
//pipe2.cpp #include |
What do you see when you execute "pipe2" ? Why? Modify the program so that it prints out the first three words of the sentence in reverse by making use of awk (see lab 2) (i.e. 'If said, Arnod....).
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
