#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Posts
    3
    Rep Power
    0

    How can I test my C++ programs in XP


    Hey, this might be an icredibly stupid question but that's just how dumb microsoft can be.

    Windows XP contains no DOS, as far as I know, C++ program testing involves DOS. So correct me if I'm wrong, but this doesn't equate. Anyhow, when I compile my programs, in either Codewarrior, or Visual C++, the program opens (the DOS window pops up) then it closes before you get a chance to read anything. I know my program is working, but obviously I want to see my programs in action. How in the hell can I test them, i contacted microsoft, they don't know a damn thing.

    Sidebar: If I'm right, and I'm not just doing something stupid, doesn't it seem retarded that Microsoft publishes a program that you can't even fully use?

    Please respond asap, how can i dodge this? Or is there a complete fix? Or is there no way to test programs in XP? Thanks for the help.
  2. #2
  3. No Profile Picture
    Offensive Member
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2002
    Location
    in the perfect world
    Posts
    622
    Rep Power
    27
    >>Hey, this might be an icredibly stupid question but that's just how dumb microsoft can be.

    Careful on who you call dumb at this point.

    >>as far as I know, C++ program testing involves DOS

    No.
    WIN32 API apps (those designed to run on MS OS's) can be written in C or C++ ect. MFC is a wrapper written by MS for C++ and WIN32 API.


    Your console app is executing and closing the console before you see the results.

    Try adding a line at the end asking for a key press before exiting.

    or use

    sleep() to pause it
    The essence of Christianity is told us in the Garden of Eden history. The fruit that was forbidden was on the Tree of Knowledge. The subtext is, All the suffering you have is because you wanted to find out what was going on. You could be in the Garden of Eden if you had just kept your f***ing mouth shut and hadn't asked any questions.

    Frank Zappa
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Posts
    3
    Rep Power
    0

    Re:


    Someone had told me that before. But it's got nothing to do with my programming, the code is fine. Any dos window in XP when started, starts up and then shuts down right away. It doesn't matter whether it's my programming, or a .bat isntaller that opens a dos windows and then closes it right away.
  6. #4
  7. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,162
    Rep Power
    2222
    Micro$oft keeps trying to bury it away deeper out of sight, but even XP, for all its Fisher-Price desktop, still has "DOS" (actually, a DOS emulation running in a "console").

    I've only had to endure that OS at school (ironically, in a Linux class no less), but I think under "Programs | Accessories" you should find a "C:>" icon labeled "Command Prompt". Open that and cd to the directory your .EXE is in and run it from there. Problem solved.

    BTW, when you cd under XP, you'll need to type the complete directory names -- no 8.3 abbreviations or wildcards allowed. Handle embedded spaces by putting quotation marks around the directory name; e.g., cd \"My Documents"

    However, if you run it from the VC++ IDE, then the problem and solution are as TechNoFear told you. The IDE spawns a console shell which in turn runs your program. As soon as your program terminates, control passes back to the shell which also terminates, its job done. And the console closes before you have a chance to see what happened.

    So to prevent your program from terminating immediately after producing the output you're interested in, you have to somehow prevent it from terminating immediately. TechNoFear's suggestions would do that.

    Myself, I always run the program from a DOS window, so I never have that problem.

    EDIT:
    You might also want to read the "console app question" thread from 02 May, which discusses the same problem.
    Last edited by dwise1_aol; May 7th, 2003 at 10:37 AM.
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Posts
    3
    Rep Power
    0

    Re:


    That's what I'm doing now, i'm trying to get around that though, because to simply test it and see how it's going i gotta shut down Codewarrior, then go through all that to test it, codewarrior would test it itself but cant. So i geuss imma have to stick with cmd prompt, even though its a pain in the arse.

IMN logo majestic logo threadwatch logo seochat tools logo