Question: Can somebody modify the program as directed. We can use popen and pclose to pass data between two processes: #include FILE * popcn(const char *command,

Can somebody modify the program as directed.Can somebody modify the program as directed. We can use popen and

We can use popen and pclose to pass data between two processes: #include FILE * popcn(const char *command, const char *type); int pclose(FILE *stream); A pipe is unidirectional, so the type argument may specify only reading or writing, not both; the resulting stream is correspondingly read-only or write-only. Use "man to study popen() and pclose(). You can read data from a pipe which connects to a command. Try the following program: //pipol.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; memsot (buffer, 0, sizeof(buffer)); //clear buffer fpi = popen ( "ps -auxw", r" ); //pipe to command ps -auxw" if ( fpi I = NULL ) { //read data from pipe into buffer chars_read = fread(buffer, sizeof(char), BUFSIZ, fpi ); if ( chars_read > 0 ) cout FILE * popcn(const char *command, const char *type); int pclose(FILE *stream); A pipe is unidirectional, so the type argument may specify only reading or writing, not both; the resulting stream is correspondingly read-only or write-only. Use "man to study popen() and pclose(). You can read data from a pipe which connects to a command. Try the following program: //pipol.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; memsot (buffer, 0, sizeof(buffer)); //clear buffer fpi = popen ( "ps -auxw", r" ); //pipe to command ps -auxw" if ( fpi I = NULL ) { //read data from pipe into buffer chars_read = fread(buffer, sizeof(char), BUFSIZ, fpi ); if ( chars_read > 0 ) cout

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!