0

My application UI (.exe file) is built by c# (windows form application project), but my algorithm is written in c++ (dynamic link library). So I create a C++/CLI project to become intermediate between my c# application and c++ library, and it works well.

I want to have a console windows together with my c# windows form application. Then I refer to this http://stackoverflow.com/questions/160587/no-output-to-console-from-a-wpf-application

I set the application output to console type and I successfully to have a console windows with my application.

My question is : I am able to print some message in my c# windows form application ( Console.WriteLine ), and it appear in console window.

But why my cout or printf function in c++ library doesn't shows in the console window ?

Am I missing any step ?

Anson Tan
  • 1,256
  • 2
  • 13
  • 34

1 Answers1

1

You are missing a step of tying the standard output handles to your created console, that does not happen automatically.

Try, if this doesn't work you will need to mess with _open_osfhand and some other calls I don't remember right off:

freopen("CONOUT$", "w", stdout);
std::cout << "This works" << std::endl;
SoronelHaetir
  • 14,104
  • 1
  • 12
  • 23