View Full Version : outputting in a command prompt from a windows app
mesman00
June 25th, 2004, 15:01
this is what i want to do. i am writing a windows app (using MFC) and want to output messages to the command prompt using the iostream lib (cout). how do i go about doing this. since i have been using java for hte last six months i know in java you can just run the executable from the command prompt and the windows app will open, yet write messages to the command prompt when needed, but i tried this in c++ and it does not work. thus, how do i go about doing this. thanks.
smcd
June 25th, 2004, 15:22
You can make a "console app" in VC++ and then use windows functions to make a window appear, and still have the console window in the background? That's what I've done in the past, it works OK, though I used WinAPI instead of MFC.
Another possibility is to have 2 separate applications, and the MFC execute the other, redirecting the STDIN of the spawned process to a pipe & the spawned console application just output everything it receives in STDIN to STDOUT.
refraction
June 25th, 2004, 15:25
the way id say is what sethmcdoogle said. if you goto Project/Properties then click Linker followed by System, the top option should be SubSystem, if you set this to console it should make a command prompt window load with your program, then you can use cout commands to output to it :)
mesman00
June 25th, 2004, 16:04
the way id say is what sethmcdoogle said. if you goto Project/Properties then click Linker followed by System, the top option should be SubSystem, if you set this to console it should make a command prompt window load with your program, then you can use cout commands to output to it :)
where is this setting. if i go to project project file menu there is no properties option, only settings. so if i open setting and go to link there is no system option. if i right click on the project and click properties there is no linker option. are you using msvc++ 6.0?
refraction
June 25th, 2004, 16:22
it shouldbe there, on you have to have the project name selected in the solution browser thing, say your project is called flob, youll see it like this
flob
sourcefiles
-main.cpp
-something.cpp
headers
-main.h
-something.h
make sure you select the project name at the top (flob in the example) before you goto the project menu.
mesman00
June 25th, 2004, 19:31
i think your thinking about .NET.
refraction
June 25th, 2004, 20:56
could be ;p but there is an equivilant somewhere in vc++ 6, just gotta look for it :)
smcd
June 25th, 2004, 22:52
Assuming VC++6 ... Alt+F7 opens project options (don't have a file selected, choose the project itself up top in the file list) and go to the Link tab. In the "Project Options:" edit box you'll see somewhere in there "/subsystem:XXXXXXX" where XXXX is gonna be either "console" or "windows" (can be other things too i imagine though not likely)
mesman00
June 28th, 2004, 14:55
yah, ok, i had already tried that. since it's an MFC app there is no main function, but the console app looks for one. thus generating the following error:
libcmtd.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
smcd
June 28th, 2004, 17:19
Yeah, I did say I've never tried that with MFC. You could go the alternate route mentioned above, and have a child program that just redirects any STDIN it gets to STDOUT? (this will work in practically ANY OS, and should do well in MFC)
GbaGuy
June 28th, 2004, 18:06
http://dslweb.nwnexus.com/~ast/dload/guicon.htm
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.