Monday, December 8, 2008

มาเรียนภาษา ซี กันเถอะ : goodbye world!

Introduction to C Programming...


#include
int main()
{
printf("Goodbye, cruel world!\n");
return(0);
}


1. Compiling and linking your source code

The compiler translates the information in the source code file into instructions the computer can understand. The linker then converts that information into a runnable program.

The GCC compiler recommended and used in this book combines the compiling and linking steps. An object file is created by GCC but it is automatically deleted when the final program file is created.

Object code files end in OBJ or sometimes just O. The first part of the object file name is the same as the source code filename.

Compiling GOODBYE.C: at terminal being in your source code's directory and then...
gcc goodbye.c -o goodbye
Nothing happen! The only time you see a message is if you made an error.

2. Running the final result
In the Unix-like operating systems, you must specify the program's path or location before the program name. Type this command.
./goodbye
Press the Enter key and the program runs, displaying this marvelous text on your screen:
Goodbye, cruel world!




1 comment:

Anonymous said...

That's a strange Hello World tutorial ;)