Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
store system() call rslt in string
Name: Vazzdoin Date: April 13, 2009 at 00:14:28 Pacific OS: Linux i686 Subcategory: C/C++
Comment:
Hi can any one tell me how to store a system() call result in a string in c++ like as , string s = system("pwd"); As such this dosn't work as the pwd is not stored in string s. Is there any other way to store the system() call result in a string. Plz reply if any one could help me to solve that problem . thanks.
Summary: is there a way to in c++ call other system functions within the program, and display the results to the screen as output? for example: system("dir c:\ /w"); i know that doesn't work, but hopefully you...
Summary: The 'system' call forks a new shell (I'm fairly sure), so it goes out, does the "cd .." and exits. Control returns and you are now in the 'old' shell and the 'old' directory. You want to use the 'chd...
Summary: if you get input from the command line: char name[255]; char ext[255]; char cmd[512]; . . . printf("enter program name-> "); gets(name); printf("enter extension-> "); gets(ext); sprintf(cmd,"ls %s|gr...