For any function that is declared to take a char* output parameter, is there a way to specify the "char" part of s std::string as the function's output?
I began with:
// EDIT: ADDED THESE TWO LINES FOR CLARITY
sprintf(buf, "top -n 1 -p %s" , commaSeparatedListOfPIDs.c_str() );
fp = popen(buf, "r");
std::string replyStr;
char reply[100];
rc = scanf( fp, "%s", reply );
replyStr = reply;
but that seems a bit, well, clumsy.
So, is there a way to say:
rc = scanf( fp, "%s", &replyStr.c_str() );
or something like that?
Thanks!