Discussion:
stdout or printf in VS output window
(too old to reply)
JFlorero
2009-02-06 00:34:02 UTC
Permalink
I have a project in C# that uses a library project that is in standard cpp.
(I had to create a Visual C++ library project to be able to call methods in
the cpp project so I can use it in the C# project).

My question is: Is it possible to redirect the output of stdout and printf
to the output window of Visual Studio? Does anybody know how to do this?
legalize+ (Richard)
2009-02-06 20:46:01 UTC
Permalink
[Please do not mail me a copy of your followup]
Post by JFlorero
My question is: Is it possible to redirect the output of stdout and printf
to the output window of Visual Studio? Does anybody know how to do this?
Not in the way I think you're asking; output of custom build steps shows
in the output window, but I think you're asking about sending output
there when you run your program in the debugger and that isn't possible
through stdout or printf. If you use ::OutputDebugString, you can send
output there, though.
--
"The Direct3D Graphics Pipeline" -- DirectX 9 draft available for download
<http://www.xmission.com/~legalize/book/download/index.html>

Legalize Adulthood! <http://blogs.xmission.com/legalize/>
JFlorero
2009-02-06 20:55:01 UTC
Permalink
If it isn't possible to see it in VS's output, is it possible to capture
stdout or printf messages using C# so I can display those messages in a log
window?
Post by legalize+ (Richard)
[Please do not mail me a copy of your followup]
Post by JFlorero
My question is: Is it possible to redirect the output of stdout and printf
to the output window of Visual Studio? Does anybody know how to do this?
Not in the way I think you're asking; output of custom build steps shows
in the output window, but I think you're asking about sending output
there when you run your program in the debugger and that isn't possible
through stdout or printf. If you use ::OutputDebugString, you can send
output there, though.
--
"The Direct3D Graphics Pipeline" -- DirectX 9 draft available for download
<http://www.xmission.com/~legalize/book/download/index.html>
Legalize Adulthood! <http://blogs.xmission.com/legalize/>
legalize+ (Richard)
2009-02-07 05:38:32 UTC
Permalink
[Please do not mail me a copy of your followup]
Post by JFlorero
If it isn't possible to see it in VS's output, is it possible to capture
stdout or printf messages using C# so I can display those messages in a log
window?
I suppose you could write a program that reads stdin and writes it to
the debug stream with OutputDebugString
--
"The Direct3D Graphics Pipeline" -- DirectX 9 draft available for download
<http://www.xmission.com/~legalize/book/download/index.html>

Legalize Adulthood! <http://blogs.xmission.com/legalize/>
JFlorero
2009-02-10 02:05:01 UTC
Permalink
Does anybody has a sample code for this?
Post by legalize+ (Richard)
[Please do not mail me a copy of your followup]
Post by JFlorero
If it isn't possible to see it in VS's output, is it possible to capture
stdout or printf messages using C# so I can display those messages in a log
window?
I suppose you could write a program that reads stdin and writes it to
the debug stream with OutputDebugString
--
"The Direct3D Graphics Pipeline" -- DirectX 9 draft available for download
<http://www.xmission.com/~legalize/book/download/index.html>
Legalize Adulthood! <http://blogs.xmission.com/legalize/>
Michael Mol
2009-02-10 02:44:31 UTC
Permalink
Something like this: http://www.rosettacode.org/wiki/Basic_input_loop#C.2B.2B

Replace the bit where it adds to the vector with calls
to ::OutputDebugString. Be mindful that code will likely only work
with MBCS, not Unicode.
Post by JFlorero
Does anybody has a sample code for this?
Post by legalize+ (Richard)
[Please do not mail me a copy of your followup]
Post by JFlorero
If it isn't possible to see it in VS's output, is it possible to capture
stdout or printf messages using C# so I can display those messages in a log
window?
I suppose you could write a program that reads stdin and writes it to
the debug stream with OutputDebugString
--
"The Direct3D Graphics Pipeline" -- DirectX 9 draft available for download
      <http://www.xmission.com/~legalize/book/download/index.html>
        Legalize Adulthood! <http://blogs.xmission.com/legalize/>
legalize+ (Richard)
2009-02-10 04:14:53 UTC
Permalink
[Please do not mail me a copy of your followup]
Post by JFlorero
Does anybody has a sample code for this?
#include <iostream>
#include <string>
#include <windows.h>

int main()
{
std::string line;
while (std::getline(std::cin, line))
{
::OutputDebugStringA((line + '\n').c_str());
}
}
--
"The Direct3D Graphics Pipeline" -- DirectX 9 draft available for download
<http://www.xmission.com/~legalize/book/download/index.html>

Legalize Adulthood! <http://blogs.xmission.com/legalize/>
Loading...