Re: compiling quistion

From: Kenneth Brody (kenbrody_at_spamcop.net)
Date: 02/01/05


Date: Tue, 01 Feb 2005 16:26:20 -0500

Jacob Oost wrote:
>
> Carramba wrote:
> > 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?

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:ThisIsASpamTrap@gmail.com>


Relevant Pages

  • RE: DOS App Runs but displays on only half screen
    ... DOS application on Windows XP full screen ... Finish the set up of the Icon ... Double click on you icon and when it opens then press ALT+ENTER and your program should run in full screen mode. ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: Installing DOS
    ... You need to own DOS and have the installation media to ... Start up the PC where you want to install the application. ... my CD icon is greyed out. ... Microsoft MVP for Virtual PC for Windows ...
    (microsoft.public.mac.virtualpc)
  • Re: Linux syscalls
    ... > A device driver or a rewrite of DOS could permit this, ... really "DOS inside Windows" or "Windows inside DOS"? ... > DOS interrupts are revectored... ... if you re-write DOS to use the _Windows device drivers_ ...
    (alt.lang.asm)
  • [Full-Disclosure] ron1n phone home, episode 4
    ... Hacking from Windows 3.x, 95 and NT ... Use secret Windows 95 DOS commands to track down and port surf computers ... Download hacker tools such as port scanners and password crackers designed ... Now you have the option of eight TCP/IP utilities to play with: telnet, ...
    (Full-Disclosure)
  • Re: Gamma Function
    ... the destructive Windows critter-makers who are ... Windows runs DOS programs ... DOS isn't a multi-tasking operating system. ... The virus itself is but a code fragment that attaches ...
    (sci.physics.relativity)