I am writing a program and i decided for input/output it would be best to allow for custom commands. I have written a config file and defined a series of commands (just echo, etc) and call these within the program using system(). The problem is that i need to get input from these commands. I tried using "read ANSWER" and then getenv("ANSWER) but this returns a null string. What is the best method to do this?
c++ get variable set by call to system()
410 Views Asked by BennyBolton At
1
There are 1 best solutions below
Related Questions in C++
- C++ using std::vector across boundaries
- Linked list without struct
- Connecting Signal QML to C++ (Qt5)
- how to get the reference of struct soap inherited in C++ Proxy/Service class
- Why we can't assign value to pointer
- Conversion of objects in c++
- shared_ptr: "is not a type" error
- C++ template using pointer and non pointer arguments in a QVector
- C++ SFML 2.2 vectors
- Lifetime of temporary objects
- I want to be able to use 4 different variables in a select statement in c ++
- segmentation fault: 11, extracting data in vector
- How to catch delay-import dll errors (missing dll or symbol) in MinGW(-w64)?
- How can I print all the values in this linked list inside a hash table?
- Configured TTL for A record(s) backing CNAME records
Related Questions in INPUT
- Trying to set the value of an input with mechanize
- Extract value of a input hidden DOMXpath php
- If Input is focused trigger X else trigger Y
- When in click a radio button, it scroll to the top. How to prenvent that?
- Numeric Keyboard display using HTML input type
- how to get user to pick inputs Java
- Input cursor windows phone phonegap
- C++ cin can't read in integers with 0 in them
- Phonegap VideoPlayer Plugin Sample Code
- Input Autofocus on type
- Why this JavaScript code does not work?
- How to input a value that has a unit as "per something"?
- Is there a standard way to capture keyboard inputs that works in a c++ application for linux and windows?
- Disable or Enable buttons based on some conditions
- How to get keystrokes with java outside of frames
Related Questions in SYSTEM
- How can I use multiple quotation marks in the system() function?
- /usr/lib/* files had been deleted, how to restore these files
- Pyaudio recognizer error cannot find path
- New Build Cursor Off Set
- Syntax error on system.out.println?
- system() occasionally returns 2
- Suppressing system command called from awk script
- How to broadcast hard key events as system broadcast in android?
- System.getProperty("os.name") Returns ... (3 dots) windows 8 java 7
- Can't call system with white space in parameter
- How to make new line when using echo to write a file in C
- c++ 2 ref classes should have acess to one same object of a other class
- How to set the environmental variable for SDK on MAC machine
- solve symbolic system of equations inside an array
- Android Studio - File Explorer doesnt show all my folders
Related Questions in GETENV
- C++ getenv doesnt update
- Strange behaviour for setenv & getenv in OS X Yosemite
- Detecting Gnome in C without GNOME_DESKTOP_SESSION_ID?
- How to prevent SERVER['HTTP_REFERER'] switches to the calling page?
- getenv() not working
- Portable way to get user name
- getenv() segmentation fault
- Which environment variables the app is using
- Can't get Environmental variables into PHP Script
- Stack smashing detected and no source for getenv
- About the method and scope of use of setenv()
- InfluxDB : cant connect with the client because of my token and os.getenv
- how to allow Java System library to access a variable defined in .zprofile?
- Methods to wrap getenv() and similar without leaks or race conditions in C
- warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Since you don't provide any code, I have to use my imagination. Let me know if I get it wrong. You are doing something like this:
And, you want to be able to read the output that is generated by that command. If I am wrong, please provide the code you are using in your question.
If I am right, then, you want to use
popeninstead. It opens a C style I/O stream. You can specify either for reading or writing (but not both). You want to use"r"for reading. Close the stream withpclosewhen you are done.