DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 9 of 9
  1. #1
    Join Date
    Jun 2005
    Posts
    13

    Question retaining the output of a program onscreen [was: what the ****]

    How come when i compile and run this this script or any script for that manner

    // my first program in C++

    #include <iostream.h>

    int main ()
    {
    cout << "Hello World!";
    return 0;
    }

    I can see the dos window appear and flash away really fast before i can read nething plz help me. -Rob

  2. #2
    Join Date
    May 2005
    Posts
    53
    I guess you run via VC. If you want to see the output, you have to run via command line. :)

  3. #3
    Join Date
    Jun 2005
    Posts
    13

    Question ???? I dont understand

    srry i dont understand what you mean im a complete newb o.0 I am pretty intellegint lol spelled that wrong ) so can you try and explain it a little bit to me thank you very much :)

  4. #4
    Join Date
    Dec 2003
    Posts
    3,366
    //try this:


    #include <iostream> //modern c++ fix
    #include <system>
    using namespace std;

    int main ()
    {
    cout << "Hello World!";
    system("pause"); //call the old dos pause routine -- adds a 'press a key' thing
    return 0;
    }

    you can also open a command window (cmd.exe -- start, run, cmd)
    and change to the location of the exe and run it from there.

    If you run from VC it adds the system pause for you -- its a nice thing mircrosoft did for you. Other compilers will not do this.

  5. #5
    Join Date
    Jun 2005
    Posts
    13

    Question Didnt work

    no that didnt work :confused:

    I also got this msg under my debugger
    \Documents and Settings\Static_Life\My Documents\C++ tutorial files\Hello World.cpp C:\Documents and Settings\Static_Life\My Documents\C++ tutorial files\C system: No such file or directory.

  6. #6
    Join Date
    Jun 2005
    Posts
    13

    Exclamation confused

    u have confused me to the brink of no return lol plz pull me back in :confused: :confused: :confused:

  7. #7
    Join Date
    Jun 2005
    Posts
    13

    help When I make a Programm.....PLZ read on

    when i make a compile and run a script or a program i have made the dos window pops up and closes before i can even read it =P plz help

  8. #8
    Join Date
    Dec 2003
    Posts
    3,366
    THere should be a version of the standard system.h include file in there -- thats the easy way. you can also read in a string, or again, simply navigate and run the program.

    start - run - cmd
    in the command box:
    cd\
    cd somefolder\otherfolder.... //go to where the program is
    myprogram.exe //you dont have to type .exe
    Last edited by jonnin; 06-29-2005 at 12:58 AM.

  9. #9
    Join Date
    Dec 2003
    Posts
    3,366
    maybe your compiler is older
    go back to iostream.h and system.h then -- those should both exist.
    system lets you do operating system commands -- like dos's dir command.
    Pause is a dos command (its for batch files).

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links