Thread: compiled but unrunable code

  1. #1
    Registered User
    Join Date
    Jun 2012
    Posts
    8

    compiled but unrunable code

    Hi

    I am just starting out using cprogramming.com's tutorials. This is my second program, it is supposed to get a number by the user then say the number back.
    Pretty simple, it is almost a carbon copy of the given code, it compiles but it does not run.
    Code:
    #include <stdio.h>
    
    int main()
    {
      int this_is_a_number;
    
      printf( "Please enter a number: " );
      scanf( "%d", &this_is_a_number );
      printf( "You entered %d", this_is_a_number );
      getchar();
      return 0;
    }
    I am using gcc on Mageia to compile, all I do is open up a terminal write "gcc Reading_numbers.c" in the teminal and press enter. It instantly spits out a file called a.out. That is the beginning of the trouble, I don't know what to do next to get it to work. I know that something I am doing is wrong but I am clueless, I have looked at other people's problems but cannot seem to find one that will help me

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Now you type in the same terminal window
    ./a.out
    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.

  3. #3
    Registered User
    Join Date
    Jun 2012
    Posts
    8
    Quote Originally Posted by Salem View Post
    type ./a.out
    Thank you

    I was so confused I even tried to run it through the conpiler again as a.out. Seeing it was such a simple answer I feel rather silly now. Thanks for explaining.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 11
    Last Post: 03-28-2012, 08:18 AM
  2. Compiled code crashing
    By cMacD in forum C Programming
    Replies: 7
    Last Post: 11-10-2011, 06:04 PM
  3. why DOS prompt crashes when I run this compiled code?
    By jackson6612 in forum C++ Programming
    Replies: 7
    Last Post: 06-03-2011, 12:58 AM
  4. Replies: 1
    Last Post: 03-12-2008, 12:10 AM
  5. C# Compiled to Machine Code
    By FwyWice in forum C# Programming
    Replies: 1
    Last Post: 12-06-2002, 04:22 AM

Tags for this Thread