Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

9th Edition

B01JXPZ7AK, 9780805360479

More Books

Students also viewed these Databases questions