Adblock breaks this site

Compiler problem

Discussion in 'Programming General' started by dam prayer noobs, Dec 12, 2009.

Thread Status:
Not open for further replies.
  1. dam prayer noobs

    dam prayer noobs Guru
    Banned

    Joined:
    Nov 27, 2005
    Posts:
    1,789
    Referrals:
    0
    Sythe Gold:
    0
    Compiler problem

    I'm new to programming so bear with me. I dled the mingw compiler along with devcpp and whenever i try to run my program the black screen momentarily appears and disappears. I downloaded the digital mars compiler also but that doesn't seem to work. I have windows 7 if that makes a difference or not. Can anyone tell me what the problem seems to be? thank you.
     
  2. Goomba

    Goomba Active Member

    Joined:
    Nov 21, 2009
    Posts:
    100
    Referrals:
    0
    Sythe Gold:
    0
    Compiler problem

    Yeahh, does your script have return(0) or system("pause")

    Please show me your script
     
  3. dam prayer noobs

    dam prayer noobs Guru
    Banned

    Joined:
    Nov 27, 2005
    Posts:
    1,789
    Referrals:
    0
    Sythe Gold:
    0
    Compiler problem

    Yeah there's nothing wrong with the script. It compiles successfully but I can't run it for some reason. Whenever I press "run" the black screen pops up and I can read the stuff but the screen just disappears like instantly after it opens.
     
  4. blindkilla

    blindkilla Guru
    $25 USD Donor New

    Joined:
    Jun 22, 2005
    Posts:
    1,896
    Referrals:
    0
    Sythe Gold:
    6
    Discord Unique ID:
    282000633404456960
    Discord Username:
    sogord
    Compiler problem

    Yea this is because you need to throw a pause in. Nothing wrong with the compiler.

    Add the include:
    Code:
    #include <stdlib.h>
    And at the end of your code (before the return) add:
    Code:
    system("PAUSE");
     
  5. dam prayer noobs

    dam prayer noobs Guru
    Banned

    Joined:
    Nov 27, 2005
    Posts:
    1,789
    Referrals:
    0
    Sythe Gold:
    0
    Compiler problem

    holy shit thank you. im following a book on it and it didn't saying anything about a system("PAUSE"); but thank you.
     
  6. Sythe

    Sythe Join our discord

    test

    Administrator Village Drunk

    Joined:
    Apr 21, 2005
    Posts:
    8,075
    Referrals:
    468
    Sythe Gold:
    5,290
    Discord Unique ID:
    742989175824842802
    Discord Username:
    Sythe
    Dolan Duck Dolan Trump Supporting Business ???
    Poképedia
    Clefairy Jigglypuff
    Who did this to my freakin' car!
    Hell yeah boooi
    Tier 3 Prizebox Toast Wallet User
    I'm LAAAAAAAME Rust Player Mewtwo Mew Live Free or Die Poké Prizebox (42) Dat Boi
    Compiler problem

    The 'black screen' is just the console window.

    Hit up start->run, type cmd.exe into the box and press enter.

    You'll need to learn to use win32 command prompt if you want to be any sort of real programmer.

    At a random search the following tutorial came up:
    http://www.febooti.com/products/command-line-email/batch-files/ms-dos-prompt-introduction.html
     
  7. super_

    super_ Member

    Joined:
    Dec 20, 2008
    Posts:
    91
    Referrals:
    0
    Sythe Gold:
    0
    Compiler problem

    lol'd: dev-c++, digital mars compiler
    oh my... ps system("pause"); is bloody disgusting
     
  8. Swan

    Swan When They Cry...
    Retired Global Moderator

    Joined:
    Jan 23, 2007
    Posts:
    4,957
    Referrals:
    0
    Sythe Gold:
    0
    Sythe's 10th Anniversary Member of the Month Winner
    Compiler problem

    Agreed.

    I suggest you try a more capable IDE like Code::Blocks. Also, never use System("pause");, use one of the stdio functions to take input from the person. Even so, I think CodeBlocks halts its own console when the program has finished executing.
     
  9. Eduard

    Eduard Member
    Banned

    Joined:
    May 26, 2006
    Posts:
    45
    Referrals:
    1
    Sythe Gold:
    0
    Compiler problem

    What happends in the code?

    Code:
    int main()
    {
    // code 
    return 0; // it returns 0, INT <-- main(). it after it has succeed it quits. so does the program. 
    }
    
    solve?
    
    int main()
    {
    //blabla
    getchar();
    return 0;
    }
    
    or 
    
    int main()
    {
    system("PAUSE");
    return 0;
    }
    
    or 
    
    use cmd.exe
    
     
< Email | Quick help needed >
Thread Status:
Not open for further replies.


 
 
Adblock breaks this site