76 976
Assignments Done
Successfully Done
In June 2019

Answer to Question #25287 in C++ for Sonya

Question #25287
char psCommand[100];
sprintf(psCommand, "%s%d%s%d%s%d%s%d", "/bin/ps -f --pppid ", getppid(), ",", getpid());

These three lines of codes are written in C sharp, how would they look like in C++??
Expert's answer
/* 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();

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!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions