Thread: GCC compile c program

  1. #1
    Registered User
    Join Date
    Sep 2010
    Posts
    9

    GCC compile c program

    I know there is tons of posts on this but I still cant seem to solve my problem. I am brand new to programming and im trying to run my test.c in GCC.

    my version is
    Charles-Aweidas-MacBook-Pro:~ charlesaweida$ gcc --version
    i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5664)
    Copyright (C) 2007 Free Software Foundation, Inc.

    I am running the file off my desktop


    Code:
    #include <stdio.h>
    int main(void){
            printf("hello world\n");
    	return 0;
    }
    when i compile it I get a large 'blank space' and thats it.
    Charles-Aweidas-MacBook-Pro:~ charlesaweida$ gcc /Users/charlesaweida/Desktop/test.c
    Charles-Aweidas-MacBook-Pro:~ charlesaweida$

    can anyone help me get up and running?
    i installed Xcode, the comand line tool compiles just fine but i cant get it to compile in the terminal, i wonder if it cant find stdio.h???

    hmmmmm

  2. #2
    Registered User
    Join Date
    May 2010
    Location
    Naypyidaw
    Posts
    1,314

  3. #3
    Registered User
    Join Date
    Sep 2010
    Posts
    9
    great, thanks!

  4. #4
    Noob AnishaKaul's Avatar
    Join Date
    Jan 2010
    Location
    Gurgaon, India
    Posts
    115
    Can you explain "blank space" meaning. The command you showed for compilation is returning the prompt as expected. Kindly explain your problem more !

  5. #5
    Registered User
    Join Date
    Sep 2010
    Posts
    9
    The compiler doesn't give me errors, but it does print "hello world"

  6. #6
    Third Eye Babkockdood's Avatar
    Join Date
    Apr 2010
    Posts
    352
    Your test.c compiled successfully, without any errors. There should be a file in /Users/charlesaweida/Desktop named a.out. This is your program, and it should print "hello world" like it's supposed to. Nothing to worry about

  7. #7
    Registered User
    Join Date
    Sep 2010
    Posts
    3
    try to compile your code with this sintax:

    Code:
    root@invecta:~# gcc -o test test.c
    if no error message shows, thats mean you successfully to compile that code. To run your result, try to type ./test

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Buidl Library with ./configure script
    By Jardon in forum C Programming
    Replies: 6
    Last Post: 07-24-2009, 09:36 AM
  2. Program Plan
    By Programmer_P in forum C++ Programming
    Replies: 0
    Last Post: 05-11-2009, 01:42 AM
  3. BOOKKEEPING PROGRAM, need help!
    By yabud in forum C Programming
    Replies: 3
    Last Post: 11-16-2006, 11:17 PM
  4. Can't compile an SDL program under Linux
    By dwks in forum Game Programming
    Replies: 2
    Last Post: 01-16-2006, 08:51 PM
  5. Replies: 4
    Last Post: 11-14-2001, 10:28 AM