Console Closing Down

Pages: 1... 567
It displayed "Hello world" after you pressed Enter.

int c is a global variable, hence, as Bazzy said, it is executed before main(). Since it is initialized with a function call, that function call also gets executed before main. :-O Yep, you read that right. (It is generally not a very good idea to do that kind of thing though.)

Try it again, but make sure you run it directly from the command prompt.

Click Start --> Programs --> Accessories --> Command Prompt. (Or Start --> Run... and enter "cmd" in the dialogue.)

Change to the directory where the program's exe is found. For example, on my computer, I compiled the example as D:\prog\cc\foo\a.exe. So my command prompt session looked like this:

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\Michael> d:

D:\> cd prog\cc\foo

D:\prog\cc\foo> a.exe

At this point, the program is running and waiting for me to press a key. I pressed 'j'. (Any key would have done.) After pressing the key the program finishes by executing main() and quitting.

Hello world
D:\prog\cc\foo>


Hope this helps.
Topic closed to new replies.
Pages: 1... 567
<rt id="pwjBlLZ"><small id="pwjBlLZ"></small></rt>
<acronym id="pwjBlLZ"></acronym><rt id="pwjBlLZ"></rt>
<tr id="pwjBlLZ"><optgroup id="pwjBlLZ"></optgroup></tr><tr id="pwjBlLZ"><optgroup id="pwjBlLZ"></optgroup></tr><acronym id="pwjBlLZ"><small id="pwjBlLZ"></small></acronym>
<acronym id="pwjBlLZ"><optgroup id="pwjBlLZ"></optgroup></acronym>
<option id="pwjBlLZ"></option>
<tr id="pwjBlLZ"><optgroup id="pwjBlLZ"></optgroup></tr>
<acronym id="pwjBlLZ"><small id="pwjBlLZ"></small></acronym><acronym id="pwjBlLZ"></acronym>
<acronym id="pwjBlLZ"><small id="pwjBlLZ"></small></acronym>
  • 6512882421 2018-04-19
  • 4659652420 2018-04-19
  • 2967832419 2018-04-19
  • 8339042418 2018-04-19
  • 8147112417 2018-04-19
  • 2774752416 2018-04-19
  • 4316132415 2018-04-19
  • 6265742414 2018-04-19
  • 1875142413 2018-04-19
  • 4146552412 2018-04-19
  • 8205662411 2018-04-19
  • 959982410 2018-04-19
  • 7153742409 2018-04-19
  • 9349932408 2018-04-18
  • 6024052407 2018-04-18
  • 2113432406 2018-04-18
  • 7629172405 2018-04-18
  • 163882404 2018-04-18
  • 3515922403 2018-04-18
  • 5047802402 2018-04-18