Console application to MFC application
I was wondering if I coded a 开发者_如何转开发program in console mode then I want to cout
everything in and MFC application, can I do that?
For example, if I had a program like
cout << "Hello World!" << endl;
Then I designed a MFC application, can I display "Hello World!" inside it? For example, like include
in PHP?
Thanks!
Assuming you are using Visual Studio , you can run the console application in MFC, provided you have checked the MFC support option . This option appears when you create a new project.
EDIT
@Ashwin - one can use cout inside an MFC app - http://pastebin.com/dAwFCCWX
@MixedCoder - Heres what you need to do - http://tinypic.com/r/34jdclt/7
No you cannot. You cannot use cout in MFC App. if you want to output some value you will have to use for ex: MessageBox("Hello World", "App", MB_OK);.
Using pipes would be the best option. Similar questions have been posted on this subject. Please refer How can I redirect stdout to some visible display in a Windows Application?
On the other hand, if you just want to create an MFC project, copy the code for the console app over to it, run it and expect to see the output in a window.. that would not work. You have to do some additional coding to achieve this.
精彩评论