beginner problem

This is a discussion on beginner problem within the C Programming forums, part of the General Programming Boards category; Okay guys, I've just started teaching myself C, right? Well, I've had a little experience with Ada, so I'm not ...

  1. #1
    Registered User
    Join Date
    Mar 2002
    Posts
    17

    Red face beginner problem

    Okay guys, I've just started teaching myself C, right? Well, I've had a little experience with Ada, so I'm not *completely* new to programming, but I'm having a little problem with these two programs that I wrote, and it's the same problem, so it's either go to be a problem with the program I'm using to write/compile/link or a problem with the code.

    The problem I'm coming across is that the dos window doesn't stay active long enough to see if my program actually ran correctly. Once I execute it, it pops up, then disappears.

    First, I'm using Miracle C to write/compile/link.

    Second, maybe you can take a look at the code, see if anything is causing the window to do that there (though it doesn't look like it *frowns*)


    #include <stdio.h>

    int radius, area;

    main()
    {
    printf( "Enter radius (i.e. 10): " );
    scanf( "%d", &radius );
    area = (int) (3.14159*radius*radius);
    printf("\n\nArea = %d\n", area );
    return 0;
    }


    Any help out there?

    ~Nymph

  2. #2
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,825

  3. #3
    Registered User
    Join Date
    Mar 2002
    Posts
    17

    gah, just figured it out

    Had to go into DOS for it to work. How embarrassing!

    Thank you for the link!
    Last edited by The_Nymph; 03-05-2002 at 01:48 PM.

  4. #4
    Code Warrior
    Join Date
    Nov 2001
    Posts
    669

    Thumbs up

    Or you can add this to your program "# include <conio.h>" and in you main function you could add "getch();" or "getchar();".
    Current projects:
    1) User Interface Development Kit (C++)
    2) HTML SDK (C++)
    3) Classes (C++)
    4) INI Editor (Delphi)

  5. #5
    Registered User
    Join Date
    Feb 2002
    Posts
    51
    Just an alternative,

    If you have the .exe in windows, you can sometimes right-click on it and go to the 'program' tab and uncheck 'close on exit'. (This may be dependent on the version of Windows you are running)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Laptop Problem
    By Boomba in forum Tech Board
    Replies: 1
    Last Post: 03-07-2006, 06:24 PM
  2. very basic beginner problem
    By sandingman1 in forum C++ Programming
    Replies: 7
    Last Post: 11-26-2005, 05:48 PM
  3. Beginner Problem
    By knoxmaddog in forum C++ Programming
    Replies: 13
    Last Post: 11-21-2005, 11:16 PM
  4. Replies: 5
    Last Post: 11-07-2005, 11:34 PM
  5. beginner problem
    By laasunde in forum C Programming
    Replies: 0
    Last Post: 11-21-2002, 08:24 AM

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