linux 编译运行c文件

在ubuntu安装gcc

编辑 test.c

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

完成后会出现一个可执行文件test,这就是编译好的文件,直接./test 就可以执行了!

原文地址:https://www.cnblogs.com/juandx/p/6771722.html