1

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!

templatetypedef
  • 362,284
  • 104
  • 897
  • 1,065
Abanoub
  • 3,623
  • 16
  • 66
  • 104
  • Is this what you want to do.. Launch the console application from the MFC app and display the console app's output in a text box (or similar control) in the MFC app? And I don't get the reference to PHP "include". – Gayan Feb 03 '11 at 07:46

3 Answers3

1

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

Sujay Ghosh
  • 2,828
  • 8
  • 30
  • 47
0

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);.

programmer
  • 878
  • 5
  • 8
  • but i will still be able to run my console program? i mean i have coded a big prgram i can run it inside the MFC – Abanoub Feb 03 '11 at 07:06
0

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.

Community
  • 1
  • 1
Gayan
  • 1,697
  • 7
  • 26
  • 35