I'd like to have the output from my console app show up immediately in an editor window when I run from inside the IDE. Dev-C++ doesn't seem to have this feature.
What I can do is pipe the output to a file using '>' and keep that file open in the editor, which automatically reloads it whenever it's modified. However, this doesn't work when running my app from the IDE. If I put "> out" in the parameter dialog, the pipe character gets passed to my app as a parameter instead of being recognized as a pipe.
What can I do here?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
save this as g++.bat in <Dev-Cpp>\bin\ .. in same location as g++.exe
now go to Dev-Cpp | Tools | Compiler Options | Programs ..
and in the g++: field .. change g++.exe to g++.bat
now .. if you have already created console_output.txt ..when you run your program a new Dev-Cpp editor window will be launched with content of console_output.cpp displayed .. note use of *.cpp extension to associate with Dev-Cpp editor.
DL
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'd like to have the output from my console app show up immediately in an editor window when I run from inside the IDE. Dev-C++ doesn't seem to have this feature.
What I can do is pipe the output to a file using '>' and keep that file open in the editor, which automatically reloads it whenever it's modified. However, this doesn't work when running my app from the IDE. If I put "> out" in the parameter dialog, the pipe character gets passed to my app as a parameter instead of being recognized as a pipe.
What can I do here?
some rough ideas ..
do you mean displaying console content in an external editor ... or in the Dev-Cpp internal editor ??
starting first with launching console_output.txt in an external editor (e.g. notepad.exe) ..
within your code .. embed command line .. something like this ..
system("notepad.exe <path_to_file>\\console_output.txt");
and if you build up console_output.txt to reflect the console content this will come up in the notepad editor (or any other editor of your choosing)
...
or instead of .. cout << "Hello World!" << endl;
use .. system("ECHO Hello World!");
...
the syntax "<", ">" or ">>" or "<<" can also be used freely inside the system(); line
...
another experiment .. to now open the console_output file ..in a Dev-Cpp internal editor window
I first tried this piping to console_output.cpp (the cpp extension to associate with Dev-Cpp)..
system("C\\Dev-Cpp\\devcpp.exe console_output.cpp");
note:- the use of "\" escape character in front of every backslash
but this command opened a second instance of Dev-Cpp ...
the solution was much simpler .. just use ..
system("console_output.cpp");
and this opened a new internal editor window in Dev-Cpp with content of console_output.cpp
I'm sure you can refine all this ..
...
ideas on use of system (); drawn from this earlier thread .. by Zero
http://sourceforge.net/forum/message.php?msg_id=1653229http://sourceforge.net/forum/message.php?msg_id=1653229
DL
typo error above ..
system("C\\Dev-Cpp\\devcpp.exe console_output.cpp");
should read (with "C:\")..
system("C:\\Dev-Cpp\\devcpp.exe console_output.cpp");
DL
I'd like to be able to do it without modifying my code
Q. do you want to launch console output in external or internal editor window?
Q. how do you now pipe the output to (say) the console_output.txt other than by modifying your code?
________________________
o.k. .. so here here is another approach
assuming you have created console_output.txt .. in same location as your cpp code
you can "break in" to Dev-Cpp by creating a batch file to be placed in C:\Dev-Cpp\bin\
here is the batch file ..
///////////////////////////////////////////////////
:: .. start of batch file named g++.bat
:: .. stored in <Dev-Cpp>\bin\
@ECHO ON
type console_output.txt > console_output.cpp
console_output.cpp
@g++ %*
:: .. end of batch file
///////////////////////////////////////////////////
save this as g++.bat in <Dev-Cpp>\bin\ .. in same location as g++.exe
now go to Dev-Cpp | Tools | Compiler Options | Programs ..
and in the g++: field .. change g++.exe to g++.bat
now .. if you have already created console_output.txt ..when you run your program a new Dev-Cpp editor window will be launched with content of console_output.cpp displayed .. note use of *.cpp extension to associate with Dev-Cpp editor.
DL
sorry .. correction .. in above batch file you will need to give the <full path> to the console_output.cpp file you create ..
@ECHO ON
cd /d C:\<path>\ console_output.cpp
@g++ %*
DL