Thread: Real Basic Question

  1. #1
    Registered User
    Join Date
    May 2005
    Posts
    3

    Question Real Basic Question

    Just a quick question... I haven't touche a C program i many years...Windows 3.11 to be exact. I am using this free compiler that was give to me from this course that I am taking...Miracle C workbench. My problem is that I have created the code, but when I run it the Dos window flashes and I cannot see the results. How do I keep that Command window open to see my output???

    Thanks for the help in advance.

  2. #2
    People Love Me
    Join Date
    Jan 2003
    Posts
    412
    Code:
    while(char a = getchar() != '\n');
    Or....
    Code:
    cin.get();
    Or if you're a fan of non-portable code....
    Code:
    system("pause");
    I guess since this is a C question that you'd probably use the first one, which can be found in stdio.h.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    > Miracle C workbench
    Well step 1 is get a real compiler, not some toy. It's passable for writing "hello world", but as soon as you know more than a couple of things, you'll realise it's a PoS.

    http://www.bloodshed.net/ and get Dev-C++, which is an IDE which comes with the rather excellent GCC compilers.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by Krak
    Code:
    while(char a = getchar() != '\n');
    Horrible code, IMO. C99 specific for one. Ugly for two.
    Quote Originally Posted by Krak
    Or....
    Code:
    cin.get();
    C++, not C.

    Of course they could have just read the FAQ.

    Quzah.
    Hope is the first step on the road to disappointment.

  5. #5
    ---
    Join Date
    May 2004
    Posts
    1,379
    Code:
    while(char a = getchar() != '\n');
    What's wrong with just
    Code:
    getchar()

  6. #6
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    First of all there's no semicolon.

    Well, if there was already something in the stream it might not work properly.

    Try this:
    Code:
    while(getchar() != '\n') ;

  7. #7
    ---
    Join Date
    May 2004
    Posts
    1,379
    First of all there's no semicolon.
    There is also no main function

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Basic question about GSL ODE func RK4
    By cosmich in forum Game Programming
    Replies: 1
    Last Post: 05-07-2007, 02:27 AM
  2. Basic C question ---- URGENT
    By x135 in forum Linux Programming
    Replies: 3
    Last Post: 03-25-2006, 11:05 PM
  3. Visual Basic Question?
    By ob1cnobe in forum C++ Programming
    Replies: 2
    Last Post: 07-03-2002, 09:31 AM
  4. A very basic question
    By AshFooYoung in forum C Programming
    Replies: 8
    Last Post: 10-07-2001, 03:37 PM