compiling quistion

C

Carramba

hi!
thanx for taking time to read my post.
code
#include <stdio.h>
int main() {
printf("Hello word!");
return 0;
}//END

when Iam compiling code with gcc I can't start program in winXP by
doubleclicking it, but if I do it with msvisual c++ I can
Why is that, and how to configure the compiler to work properly?
 
K

Kenny McCormack

hi!
thanx for taking time to read my post.
code
#include <stdio.h>
int main() {
printf("Hello word!");
return 0;
}//END

when Iam compiling code with gcc I can't start program in winXP by
doubleclicking it, but if I do it with msvisual c++ I can
Why is that, and how to configure the compiler to work properly?

I call BINGO!
 
J

Jacob Oost

Carramba said:
hi!
thanx for taking time to read my post.
code
#include <stdio.h>
int main() {
printf("Hello word!");
return 0;
}//END

when Iam compiling code with gcc I can't start program in winXP by
doubleclicking it, but if I do it with msvisual c++ I can
Why is that, and how to configure the compiler to work properly?

I thought under Windows GCC was called something else, like DJPP or
EGCS. Anyway, I believe this is because XP has really, really, really
crappy backwards support, like for old DOS programs (even worse legacy
support than 95/98 did). XP sees a program that calls the printf()
function and says, "Oh, a DOS program, I'll just sit here and do nothing
while he double-clicks like mad." You would have to open a DOS shell
and enter the prog.exe command or fiddle with the properties somehow
(forget exactly how, let's just say that getting DOS games, even ones as
recent as 1995, to run on XP is a chore) to run your little Hello World
in a DOS shell automatically. Visual Studio, OTOH, has a built-in DOS
shell, because they know that plenty of people (students, for instance)
will be writing programs to learn on that only use the standard
libraries and no WIN32 stuff.

Isn't XP grand?

--

----- BEGIN GEEK CODE BLOCK -----
Version 3.1
GAT d? !s !a C++++ UL+ P L++ E- W+ N+ o-- K- w--
O- !M !V PS-- PE++ Y+ PGP- t++>++++* 5? !X-- R- tv b++ DI+ D++
G e !h !r !y
...... END GEEK CODE BLOCK ----
 
C

Chris Williams

Just to translate that:

If you open the command prompt (the thing that looks like DOS) and run
the application from that then the application will write "Hello
world!"
Windows by itself doesn't have anywhere to show it, so you need to do
it in the command prompt.

-Chris
 
J

Jacob Oost

Chris said:
Just to translate that:

Saying obfuscated was I, were you, eh?

--

----- BEGIN GEEK CODE BLOCK -----
Version 3.1
GAT d? !s !a C++++ UL+ P L++ E- W+ N+ o-- K- w--
O- !M !V PS-- PE++ Y+ PGP- t++>++++* 5? !X-- R- tv b++ DI+ D++
G e !h !r !y
...... END GEEK CODE BLOCK ----
 
J

Jonathan Burd

Carramba said:
hi!
thanx for taking time to read my post.
code
#include <stdio.h>
int main() {
printf("Hello word!");
return 0;
}//END

when Iam compiling code with gcc I can't start program in winXP by
doubleclicking it, but if I do it with msvisual c++ I can
Why is that, and how to configure the compiler to work properly?

<ot>
Let me guess. Double-clicking the executable opens a
command window, executes the program before you can see the output,
and vanishes? Learn to use the command-line instead of that
point-n-click thing.

However, here is one solution to the problem:
------
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\exefile\shell\runcmd]
@="Run in Console"

[HKEY_CLASSES_ROOT\exefile\shell\runcmd\command]
@="cmd /k \"echo Executing (Press Ctrl+C to end
program)...&&\"%L\"&&pause&&exit\""

[HKEY_CLASSES_ROOT\batfile\shell\runcmd]
@="Run in Console"

[HKEY_CLASSES_ROOT\batfile\shell\runcmd\command]
@="cmd /k \"echo Executing batch script...&&\"%L\"&&pause&&exit\""
------

Put the lines between the ------ markers in a file
called run_in_console.reg and double-click it.
Click Yes to merge it with your registry.
(If it didn't work, add these entries manually using regedit;
and these are for XP only.)

This will enable a new menu command when you right-click on
exe files. Use it.
</ot>

Regards,
Jonathan.
 
C

Chris Williams

If you were what you say I implied your statement was then that
wouldn't make sense.

-Chris
 
R

Richard Bos

Chris Williams said:
If you were what you say I implied your statement was then that
wouldn't make sense.

Without any context, _nothing_ makes sense. If you _must_ use Google-
broken-beta, learn to use it properly.

Richard
 
J

Jacob Oost

Chris said:
If you were what you say I implied your statement was then that
wouldn't make sense.

-Chris

Gimme a minute....was I insulted just now?

--

----- BEGIN GEEK CODE BLOCK -----
Version 3.1
GAT d? !s !a C++++ UL+ P L++ E- W+ N+ o-- K- w--
O- !M !V PS-- PE++ Y+ PGP- t++>++++* 5? !X-- R- tv b++ DI+ D++
G e !h !r !y
...... END GEEK CODE BLOCK ----
 
K

Kenneth Brody

Jacob said:
I thought under Windows GCC was called something else, like DJPP or
EGCS. Anyway, I believe this is because XP has really, really, really
crappy backwards support, like for old DOS programs (even worse legacy
support than 95/98 did). XP sees a program that calls the printf()
function and says, "Oh, a DOS program, I'll just sit here and do nothing
while he double-clicks like mad." You would have to open a DOS shell
and enter the prog.exe command or fiddle with the properties somehow
(forget exactly how, let's just say that getting DOS games, even ones as
recent as 1995, to run on XP is a chore) to run your little Hello World
in a DOS shell automatically. Visual Studio, OTOH, has a built-in DOS
shell, because they know that plenty of people (students, for instance)
will be writing programs to learn on that only use the standard
libraries and no WIN32 stuff.

Isn't XP grand?

What version of XP are you using that does that? None of the versions I
have come anywhere close to your description.

This is getting off-topic for c.l.c, but the "problem" is that the program
starts, runs, and exits faster than the OP can see it. Yes, XP created a
console window automatically when the icon was double-clicked. There is
nothing special about running under Visual Studio, aside from the fact
that it will put a "press any key to continue" prompt for you when you do
so.

Try this (untested) modification:

#include <stdio.h>
int main() {
printf("Hello word!");

printf("\n\nPress Enter to continue.\n");
fflush(stdout);
while ( getchar() != '\n' )
;

return 0;
}//END

Or, for a Windows-specific "solution", change the properties of the icon
to not close upon exit.

--
+-------------------------+--------------------+-----------------------------+
| Kenneth J. Brody | www.hvcomputer.com | |
| kenbrody/at\spamcop.net | www.fptech.com | #include <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------------+
Don't e-mail me at: <mailto:[email protected]>
 
K

Kenny McCormack

and what exactly it suppose to mean?

The instant you mention things like either "winXP" or "msvisual c++"
you invoke the fury of the topicality police.

You might want to google for "breeder bingo"...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,159
Messages
2,570,879
Members
47,416
Latest member
LionelQ387

Latest Threads

Top