468,484 Members | 1,675 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,484 developers. It's quick & easy.

stdlib system() cout

7
When you call the system function() with any parameter it prints text to the console, I wonder if you can get this text into a string variable.
Jan 25 '08 #1
3 3974
Ganon11
3,652 Expert 2GB
Can you clarify your question? Do you mean use a string in your system() call instead of typing in a literal string? Do you mean storing the output of, say, another program and catching that in a string back in your C++ program?
Jan 25 '08 #2
gpraghuram
1,275 Expert 1GB
When you call the system function() with any parameter it prints text to the console, I wonder if you can get this text into a string variable.

You have to redirect the output of the system call to a file and then read it.
like this
Expand|Select|Wrap|Line Numbers
  1. char array[100]="ls > outfile";
  2. system(array);
  3.  
  4. //open and read the outfile
  5.  
  6.  
Thanks
Raghuram
Jan 25 '08 #3
Saile
7
Thanks, the "> outfile" solves my question.
Jan 25 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

6 posts views Thread by JLK | last post: by
7 posts views Thread by Baloff | last post: by
2 posts views Thread by nickyeng | last post: by
1 post views Thread by Sean | last post: by
3 posts views Thread by jchimanzi | last post: by
4 posts views Thread by jchimanzi | last post: by
1 post views Thread by jchimanzi | last post: by
4 posts views Thread by JShrager | last post: by
21 posts views Thread by Anton Dec | last post: by
reply views Thread by NPC403 | last post: by
2 posts views Thread by gieforce | last post: by
reply views Thread by theflame83 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.