Thread: Is my compiler compatible with C?

  1. #1
    Registered User
    Join Date
    May 2010
    Location
    Essex, UK
    Posts
    6

    Is my compiler compatible with C?

    Hey, I've been using Dev Bloodshed for all my C++ learning needs however I have began reviewing the C tutorials on the site and testing some examples. The problem is none of the examples are running how they should, the getchar(); function can't be functioning properly as it closes straight after I press enter and I cannot see more than one bit of out put when I run a program.

    Code:
    #include <stdio.h>	
    
    int main()                            /* Most important part of the program!
    */
    {
        int age;                          /* Need a variable... */
      
        printf( "Please enter your age" );  /* Asks for age */
        scanf( "%d", &age );                 /* The input is put in age */
        if ( age < 100 ) {                  /* If the age is less than 100 */
         printf ("You are pretty young!\n" ); /* Just to show you it works... */
      }
      else if ( age == 100 ) {            /* I use else just to show an example */ 
         printf( "You are old\n" );       
      }
      else {
        printf( "You are really old\n" );     /* Executed if no other statement is
        */
      }
      getchar();
      return 0;
    }
    For instance this program runs and closes the second I type in my age and hit enter, it does not give me another output. I'm positive it's not the code but if it's my compiler what should I do to resolve this issue? Thanks.

  2. #2
    Registered User
    Join Date
    May 2010
    Location
    Naypyidaw
    Posts
    1,314
    This kind of question is the Most Frequently Asked Question. (MFAQ)
    c-faq

  3. #3
    Registered User
    Join Date
    May 2010
    Location
    Essex, UK
    Posts
    6
    Sorry, cheers for pointing that out to me.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiler Paths...
    By Cobra in forum C++ Programming
    Replies: 5
    Last Post: 09-26-2006, 04:04 AM
  2. C Compiler and stuff
    By pal1ndr0me in forum C Programming
    Replies: 10
    Last Post: 07-21-2006, 11:07 AM
  3. I can't get this new compiler to work.
    By Loduwijk in forum C++ Programming
    Replies: 7
    Last Post: 03-29-2006, 06:42 AM
  4. how to call a compiler?
    By castlelight in forum C Programming
    Replies: 3
    Last Post: 11-22-2005, 11:28 AM
  5. Help With finding a compiler
    By macman in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 04-15-2005, 08:15 AM