How can i assign the ouput from system("ping myIP") to a variable on the linux platform. Im actually using a program called ding which prints an integer to the consoe. I need to redirect the output from the console to the variable.
How can i assign the ouput from system("ping myIP") to a variable on the linux platform. Im actually using a program called ding which prints an integer to the consoe. I need to redirect the output from the console to the variable.
popen() is probably the easiest thing to use
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
Thanks I think ive got it working with.
Thanks againCode:FILE *fp; char line[10]; fp = popen("ding -s -r 202.......", "r"); while ( fgets( line, sizeof line, fp)) { cout << "result is " << line << endl; } pclose(fp);