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++
- How to immediately apply DISPLAYCONFIG_SCALING display scaling mode with SetDisplayConfig and DISPLAYCONFIG_PATH_TARGET_INFO
- Why can't I use templates members in its specialization?
- How to fix "Access violation executing location" when using GLFW and GLAD
- Dynamic array of structures in C++/ cannot fill a dynamic array of doubles in structure from dynamic array of structures
- How do I apply the interface concept with the base-class in design?
- File refuses to compile std::erase() even if using -std=g++23
- How can I do a successful map when the number of elements to be mapped is not consistent in Thrust C++
- Can std::bit_cast be applied to an empty object?
- Unexpected inter-thread happens-before relationships from relaxed memory ordering
- How i can move element of dynamic vector in argument of function push_back for dynamic vector
- Brick Breaker Ball Bounce
- Thread-safe lock-free min where both operands can change c++
- Watchdog Timer Reset on ESP32 using Webservers
- How to solve compiler error: no matching function for call to 'dmhFS::dmhFS()' in my case?
- Conda CMAKE CXX Compiler error while compiling Pytorch
Related Questions in INPUT
- Player input not working properly in unity
- Getting data attributes from HTML input element with a datalist
- how to find sum of input value in javascript
- Terminal stimulation
- C#: creating an array and appending console input to each value
- How do i make a text inside disabled <v-text-field> selectable (simply to copy and paste somewhere else)?
- C++ File Input Skipping Lines
- React text box not taking input
- Trying to build a Generative Adversarial Network to generate images based on captions but facing errors with input shapes
- Video controls are hidden behind input feature?
- How can I edit a todo list on the same input where add todo in React?
- Stopping code while the input line is running
- Store Gum Input in variable?
- Detect password manager (or chromium) autofill for websites
- How can I make sure that my Selector does not overlap my text-area box when hover ? I would like for the selector to smoothly push down the text-area
Related Questions in SYSTEM
- Network System - Cisco Packet Tracer
- How to make Python script use a designated directory as source for imports (from within the script)?
- Setting Up a Remote Employee Clocking System with Biometric Recognition
- How to use mmap iteratively to map data in small chunks from a large file
- Confusing Wording in SSH-CONNECT [RFC4254]
- which programming language is suitable for this task?
- How to replace standard call to System.currentTimeMillis() via AspectJ?
- Android's Google services error, something with Magisk and Zygote SIGABRT (SIGNAL 6)
- Electron, system notification and playing sound
- Python solver returns no values upon running the code
- The system automatically restarts when opening the browser, IntelliJ IDEA, or WebStorm. How can I resolve this issue?
- Running a python program as a system service on Ubuntu 22
- Best multi-threaded epoll architecture? (also question about EPOLEXCLUSIVE flag)
- error in saving tiff files to a pdf file using ghostscript win64c
- All permissions Android system
Related Questions in GETENV
- How to do getenv for a value stored in a char* string variable
- why are all environment-variables (null)
- (C) How do I include a directory path after a getenv()?
- secure_getenv function not giving the expected result
- Moodle Config file using docker env
- Thread safe initialization of string from getenv (environment variable)
- Python - How to use os.getenv with Path().resolve()
- Failing to set environment variable
- chdir(getenv("HOME") returns Bad address
- How do I use environment variables (repl.it) to create an array?
- To print the environment from the stdin (var name) & execute the getenv() function it compiles correctly but no output what am i missing?
- About the method and scope of use of setenv()
- InfluxDB : cant connect with the client because of my token and os.getenv
- Why get env vars in php 7 is not working?
- System.getenv with special characters like '%' in Java
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 # Hahtags
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.