Thread: help with compile and run on c++

  1. #1
    Registered User
    Join Date
    Apr 2009
    Posts
    4

    Exclamation help with compile and run on c++

    ,hello and sorry for the hastle but i have windows vista and windows xp computers at home and i installed the latest version of c++ however when i wite a simple program in the editor the black c window that should appear. just flashes and then dissapears
    for a bit more complex programs where i had to insert an integer the black screen would appear but as soon as i inserted the integer and pressed enter it would disapear without giving me the answer.

    if anyone could help it would save me i have an exam soon..
    thank youu

  2. #2
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675

  3. #3
    Registered User
    Join Date
    Apr 2009
    Posts
    4
    thanks a lot ill give it a try

  4. #4
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    You are writing a console program. You should run it from the console. These getchar() or cin.get() tricks are dumb.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  5. #5
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Even better is an IDE that prevents the window from disappearing. Visual Studio can do it, and Code::Blocks supposedly can too, but I don't know how.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  6. #6
    Hail to the king, baby. Akkernight's Avatar
    Join Date
    Oct 2008
    Location
    Faroe Islands
    Posts
    717
    Ctrl + F5 in Visual Studio does it...
    I believe Code::Blocks just did it automaticly... Don't remember 100% tho xP

    And no offence, but I believe a simple search on Google would have been faster...
    Currently research OpenGL

  7. #7
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by Akkernight View Post
    Ctrl + F5 in Visual Studio does it...
    I believe Code::Blocks just did it automaticly... Don't remember 100% tho xP

    And no offence, but I believe a simple search on Google would have been faster...
    To keep the console around, specify:

    Code:
    cmd.exe /K prog.exe
    If the IDE allows you to change the command which is used to launch a console program, just add "/K" to it.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  8. #8
    Registered User
    Join Date
    Apr 2009
    Posts
    4
    thanks everyone. really appreciate the help.!!

  9. #9
    Registered User
    Join Date
    Apr 2009
    Posts
    4
    #include <stdio.h>

    int main()
    {
    printf(" @@@@@ \n");
    printf(" @@@@@@@ \n");
    printf(" @@@@ _ _| \n");
    printf(" @@=-[0]0] \n");
    printf(" @( _| \n");
    printf(" @ V \n");
    printf(" |___| \n");
    printf(" ^^^^^ \n");
    printf(" ^^^^^^^ \n");

    return 0;

    }


    sorry guys but i tried everything with this program and the black screen will just continue to disappear
    plus i didnt understand what exactly i have to do.

  10. #10
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    Read the FAQ link posted up above. Or just add getchar() to the line above your return statement.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 07-13-2008, 08:16 PM
  2. Replies: 5
    Last Post: 10-25-2007, 12:27 PM
  3. Dev-C++ Compile and Run with Pause
    By xmltorrent in forum C++ Programming
    Replies: 12
    Last Post: 03-29-2006, 11:55 PM
  4. Cant compile and run
    By Vente in forum C++ Programming
    Replies: 5
    Last Post: 12-27-2005, 02:11 PM
  5. Replies: 4
    Last Post: 11-14-2001, 10:28 AM