2013-02-26T20:55:54-05:00
char psCommand[100];
sprintf(psCommand, "%s%d%s%d%s%d%s%d", "/bin/ps -f --pppid ", getppid(), ",", getpid());
system(psCommand);
These three lines of codes are written in C sharp, how would they look like in C++??
1
2013-02-28T09:06:28-0500
/* First of all the code you gave is written in C. Here's how will it look in C++ */ #include <string> #include <sstream> #include <cstdlib> #include <unistd.h> using namespace std; int main() { ostringstream psCommand; psCommand << "/bin/ps -f --pppid "; psCommand << getppid() << "," << getpid(); system(psCommand.str().c_str()); return 0; }
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS !
Learn more about our help with Assignments:
C++
Comments