linux c/c++ beginer

XEmacs

Editors in the Linux environment are usually completely separated from compilers and compiler tools, such as make. Source code is written with a text editor and the source file is compiled afterwards.
There are also editors that integrate compilers so that the compiling can be carried out within the editor. One such editor is XEmacs. In order to use XEmacs conveniently, the .profile file in user's home directory should contain the following lines:

PATH="$PATH:/opt/xemacs/bin"
export PATH

After this modification XEmacs editor can be executed with a command xemacs. For additional information on XEmacs, please visit www.xemacs.org.


GCC

Compiling "C" And "C++" Programs On Unix Systems - gcc/g++
http://users.actcom.co.il/~choo/lupg/tutorials/c-on-unix/c-on-unix.html

GCC how to
http://doc.99net.net/doc/soft/1076980860/index.html


列一:fork.c

#include
#include
#include

void main(void)
{
pid_t pid;

printf("hello/n");
pid = fork();

switch (pid) {
case -1: printf("failure!/n"); break;
case 0: printf("I am child!/n"); break;
default: printf("my child is %d/n",pid); break;
}
for (; ; ) { /* do something here */ }
}

編譯:

gcc -o ex1 fork.c

執行結果:

./ex1 &

hello
my child is 8650
I am child!

C++ Reference Guide
http://www.informit.com/guides/guide.asp?g=cplusplus&rl=1

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章