Qtcreator get stdin from a file instead of terminal - c++

I am making a program that reads from stdin.
I want to debug the program in qtcreator but I can't find a way of providing input except using the terminal. Which is not very practical because my input is a big file with a lot of lines.
I tried going to the run options of qtcreator and insert the following in the Command Line Arguments: < filename
But Qtcreator gave me an error in the application output:
14:26:54: Debugging complex shell commands in a terminal is currently not supported.
Is there no way of providing a file as stdin in qtcreator?

Related

How do I use a text file for stdin input in DEV C++ IDE?

I am trying to use a .txt file for my stdin in a c++ program. Essentially, I am just trying to find where in this IDE (Dev C++) I would be able to specify the file I want to use for program input.
I thought that I would be able to read file input here:
But this doesn't seem to be working. I have tried with a space between the 1 and the file name and with quotes around the file name.
I know my program allows for the file to be read properly because when running it in the command line it outputs the first line of the stdin file, test01.txt.
The command I am using to run the program in cmd line is: ./prog 1 < test01.txt where 1 is a case number for a switch statement and test01.txt is input used by that switch statement.
How would I mimic this command line call in Dev C++ IDE? The test01.txt file is part of my project files...

Xcode 8.3: Run target with input from file

I wrote a simple C++ program that requires some input to run. In the terminal I simply run in ./myProgram < fileWithData.txt. However I could not figure out how to specify and input file for the target executed in Xcode. I used the command line project. Of course I could use a different target, for example run Terminal.app and then pass it the executable with the input file but then I can no longer debug it.
This question: Cannot get lldb to read file input explains how to set the input path in lldb, but I could not find a way to specify lldb commands that are executed before the process is started.
I don't think there's a way to do this entirely from within Xcode. However if you set the Run Scheme in Xcode to the launch mode "Wait for executable to be launched," hit run, and then run your program from Terminal.app with the appropriate piping, the Xcode-embedded lldb will connect to it.

Xcode won't pass arguments to C++ executable

I'm attempting to debug a C++ project using Xcode. My program looks for input through stdin like so:
string line;
getline(cin, line);
I have an input file called input.txt that I normally pass into the executable like so:
./verti < input.txt
In order to accomplish the same thing while debugging in Xcode, I've added an argument to be passed on launch by Product > Scheme > Edit Scheme... > Run > Arguments with a value of < input.txt. The text file is located in the same working directory as the executable, yet when I build/run the program, the text file isn't being passed in. The program just waits for input that it should receive. If you guys could lend any insight, that'd be really helpful.
I'm running Xcode 6.3.1 on OS X 10.10.1.
The < is actually interpreted by the shell (when using a terminal and the command line). In case of Xcode there is no shell involved, so you can't pipe input to stdin.
You have to open the file (in argv[1]) in your process and use the file descriptor instead of stdin.

Setting up build command to get the runtime of C++ program in Geany

Is there any way that I can see the run time of my C++ program in Geany? I am trying to add a execute command like this "time(./%e<i.txt)" it is giving error
./geany_run_script.sh: 5: ./geany_run_script.sh: time(./g<i.txt): not found
I have i.txt in the same directory as output file.I just want to know the runtime of my C++ programs while taking input from .txt file without writing the commands every time in the terminal myself any way I can do this?

How do redirect STDOUT out of XCode compiled Command Line executable?

I have a C++ program that writes to stdout that I am trying to compile into a command line utility in XCode. I need the program compiled into a release build (which it seems, XCode calls an Archive - go figure), not run it as debug.
I basically want to pipe the output of my program into a textfile like this
MyProgram > TextFile.txt
I can compile the program into a command line and run it like this via a Bash shell like this:
Open MyProgram
This spawns a new process (not what I want). However, I could live with that if this worked:
Open MyProgram > TextFile.txt
...But it doesnt :-(. If I try to just run MyProgram directly from Bash, I get the error: -bash: MyProgram: command not found.
What am I doing wrong? How can I compile my command line tool to NOT require the Open command under Mac OSX?
Thanks for any help you can provide. I am picking up C++ on the Mac platform and I am beginning to find it quite it a bit more troublesome than Visual Studio. Does it ever get less painful to work with? :-)
Make your project a Command Line Tool. This will make it so you can run it from the command line directly.
Run it by typing ./MyProgram or ./MyProgram > TextFile.txt not open MyProgram.