help with compile and run on c++

This is a discussion on help with compile and run on c++ within the Windows Programming forums, part of the Platform Specific Boards category; ,hello and sorry for the hastle but i have windows vista and windows xp computers at home and i installed ...

  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
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,648

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

  4. #4
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,235
    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をこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,428
    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
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,235
    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,246
    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, 10:55 PM
  4. Cant compile and run
    By Vente in forum C++ Programming
    Replies: 5
    Last Post: 12-27-2005, 01:11 PM
  5. Replies: 4
    Last Post: 11-14-2001, 09:28 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21