PPRuNe Forums - View Single Post - doing C
Thread: doing C
View Single Post
Old 23rd September 2010 | 21:03
  #5 (permalink)  
bnt
15 Anniversary
 
Joined: Feb 2007
Posts: 755
Likes: 26
From: Dublin, Ireland. (No, I just live here.)
I did a basic C / C++ course at university, and compiled some of my programs on this Ubuntu Netbook. The base compiler is called gcc, but I don't think it is installed by default, since it pulls in a bunch of other stuff too. If not, just do a "sudo apt-get install gcc" to install it.

With this code in hello.c:
Code:
/* hello.c: display a message on the screen */

#include <stdio.h>
 main()
{
 printf("hello, world\n");
}
you compile it with
Code:
gcc -o hello hello.c
and run it with command
Code:
./hello
NB: the -o parameter sets the output executable name. If you're writing C++, use g++ instead of gcc, but I generally used g++ for everything, even plain C.
bnt is offline  
Reply