473,385 Members | 1,736 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 4123
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

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

Similar topics

6
by: JLK | last post by:
I'm having a bit of a time with the following code. I can script this real easy in Bash but I'm trying to practice my C++: ******************************************************* #include...
7
by: Baloff | last post by:
Hello I have this line in my c++ code and it is giving the error below, not sure why, I tried it on different boxes, same error. thanks the last line in my main() I have this system(...
2
by: nickyeng | last post by:
i have a function that clear the screen and then display array to cout. i compiled no error no warning, i run it, the screen really get "clear" but it does not display anything to cout, and it...
1
by: Sean | last post by:
Hi, I am trying to write a simple chat/text messaging program but I am having some problems. I am a rookie when it comes to socket programming so I am not sure if I am doing the write thing or...
3
by: jchimanzi | last post by:
I am trying to develop a small program which does library books. I have tried the code below but it still does not work. Can someone help me to debug the program and advice accordingly. ii) //...
4
by: jchimanzi | last post by:
Please can someone help in correcting the following attempt of the questions below. I have included my attempt at the problem I have been asked to write class definations which does the following...
1
by: jchimanzi | last post by:
Can someone check this program for me to see if its correct. I need to have a program which is able to add books,add customers, allow customer x to take out book y, and print out report v) Void...
4
by: JShrager | last post by:
I just upgraded my server to a recent version of redhat, and now old code no longer compiles. I'm not a C++ coder, but C++ coders who use my server are now complaining. Here's an example: ...
21
by: Anton Dec | last post by:
Just curious about this... malloc is defined in stdlib.h, right? But if I write a program without #include<stdlib.hand use malloc, it still works as expected. Why is this? Is malloc...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.