linux 編譯運行c文件

在ubuntu安裝gccubuntu

編輯 test.ccode

/* Not stdio.h */
#include <unistd.h>
 
void main()
{
    char str[100];
 
    /*Write on screen*/
    write(1,"\nType Something : ",17);
 
    /*Read at most 100 chars from console into 'str' */
    read(0,str,100);
 
    write(1,"\nYou typed :\n",13);
 
    /*write 10 chars from 'str' to screen */
    write(1,str,10);
 
    /*newline*/
    write(1,"\n",1);
}
# gcc -o test test.c

完成後會出現一個可執行文件test,這就是編譯好的文件,直接./test 就能夠執行了!it

相關文章
相關標籤/搜索