473,396 Members | 1,784 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

FAQ Where did my console output go?

One of the many questions asked by people is that even if they write
into standard output, the output doesn't show in the screen. This
happens in windows systems since quite a long time.

To avoid this, you should open a console before outputting anything
into standard output. You do this with

void AllocConsole(void);

When you do not want to use the console any more (and you do not
want the ugly black window hanging around) you just do:
BOOL WINAPI FreeConsole(void);

The operating system opens up a console for all programs that
have the bit of "console application" set in the executable. That is
why you do NOT needto open a console for those programs. Programs
that need this are only programs that were compiled with the
"subsystem windows" bit set.

-------------------------------------------------------------------

You find this off topic for clc?

You can go to hell. There, you can complain to the boss.

You find me obnoxious?

You can go to heaven and complain there to the boss.

--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
Nov 1 '08 #1
5 2995
In article <ge**********@aioe.org>, jacob navia <ja***@nospam.orgwrote:
>One of the many questions asked by people is that even if they write
into standard output, the output doesn't show in the screen. This
happens in windows systems since quite a long time.

To avoid this, you should open a console before outputting anything
into standard output. You do this with

void AllocConsole(void);
Some additional points:
1) (As noted by others) You don't need any of this if you "just want
standard C" and want to appease the topicality police. You just
compiler your program as a console mode app and pretend that the
last 25 years of progress in OS functionality didn't happen.
2) (And therefore) You really only need this when you want to use
Windows qua Windows and also want Old World "standard I/O" as well.
3) I seem to remember that early Windows compilers had a way to
automatically "Windows-ize" stdio programs - i.e., it would open up
a Windows-y window for you and direct stdout there (and also had a
facility for reading the keyboard). I don't know if current
compilers support this. If so, this would be the best advice for
would-be C programmers working under Windows.
4) I think there's a little more to it than just AllocConsole() - having
been there and done that, as they say. You also have to do
GetStandardHandle() and jump through a couple of other hoops.

Nov 1 '08 #2
jacob navia wrote:
>
You can go to hell. There, you can complain to the boss.
Your recent descent from obnoxiousness to deliberate
offensiveness forces another action on me.

--
Eric Sosman
es*****@ieee-dot-org.invalid
Nov 1 '08 #3
Eric Sosman wrote:
jacob navia wrote:
>>
You can go to hell. There, you can complain to the boss.

Your recent descent from obnoxiousness to deliberate
offensiveness forces another action on me.
yes?

Go ahead
do whatever you feel like
--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
Nov 1 '08 #4
jacob navia <ja***@nospam.comwrites:
[...]
void AllocConsole(void);
[...]

That is not the correct declaration for AllocConsole. According to
Microsoft's own online documentation, the correct declaration is

BOOL WINAPI AllocConsole(void);

Presumably BOOL is some Boolean type (most likely not _Bool, since I
understand Microsoft's compiler doesn't support C99). My guess is
that WINAPI is some sort of macro or extension that specifies
something about the calling convention.

Richard Heathfield pointed out in another thread that the declaration
is incorrect; if he hadn't, I would have assumed you had gotten it
right. If you post Windows-specific information here in comp.lang.c,
and you happen to get something wrong, it's very likely that nobody
will correct your error. If, on the other hand, you had posted to,
say, comp.os.ms-windows.programmer.win32, then your information could
have been checked by other people who actually use AllocConsole.

Getting the declaration for AllocConsole wrong isn't a huge deal. We
all make mistakes; I certainly do. Posting such information *here*,
however, runs a substantial risk of misleading people.

This is why we have different newsgroups.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Nov 1 '08 #5

"Eric Sosman" <es*****@ieee-dot-org.invalidschreef in bericht
news:ge**********@registered.motzarella.org...
jacob navia wrote:
>>
You can go to hell. There, you can complain to the boss.

Your recent descent from obnoxiousness to deliberate
offensiveness forces another action on me.
you are touching yourself now?
Nov 2 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Max | last post by:
Hi All, I am developing an application that needs to run in one of two modes: 1. If No command line param is provided the application should run as Window form. 2. If command line param is...
1
by: Oz | last post by:
This is long. Bear with me, as I will really go through all the convoluted stuff that shows there is a problem with streams (at least when used to redirect stdout). The basic idea is that my...
2
by: Boba | last post by:
Hi, I'm programming a WinForm application. I would like to enter commands that will send output that will help me to locate bugs in the future. I know that there is a way to send output by...
7
by: ajikoe | last post by:
Hello All, It is said that : Enabling the console window is easy. From Microsoft Visual Studio®, right-click on the project and choose Properties. Change the output type from Windows Application...
5
by: Barry Mossman | last post by:
Hi, can I detect whether my class is running within the context of a Console application, vs say a WinForm's application ? also does anyone know whether the compiler or runtime is smart enough...
1
by: noleander | last post by:
Hi. I've got a C++ program written in Visual C++ 2003. The program is trivial, created with the Program-creation wizard: used the .NET "Form" template. The program has a trivial...
4
by: Bob | last post by:
I just recently noticed that when I start my applicatoin in debug mode, the IDE hangs (no disk or CPU activity) indefinitely (at least 20 minutes). Pausing the application shows that it's hung up...
2
by: Steve | last post by:
I have created a console app that simply prints out a message a couple times, then exits, here is the code: <code> for(int i = 0; i < 10; i++) { System.Threading.Thread.Sleep(500);...
3
by: Andrew Ducker | last post by:
We were using Console.Writeline from within our app, to do some routine debugging. And then we started having random problems when the code was run by a tester, on their own machine. We...
3
by: TC | last post by:
I'm trying to debug a console application, but I can't see the console output. I've seen many references which say that console output is supposed to appear on the Output window when the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.