在Ubuntu下的C语言编程

以运行在虚拟机下的Ubuntu为例:

mkdir fenchen  来创建一个文件夹

cd fenchen  切换到这个文件夹下面

vi test.c  创建并编辑一个test.c文件

按 i 编辑,之后把下面这段代码输入

#include <stdio.h>

int main()
{
    printf("Hello World!\n");
  return 0; }

输入进去之后按Esc退出编辑,然后输入:wq或者:x,别忘了:(冒号),如图

 

 gcc test.c -o test  编译test.c文件

最后输入

./test

运行这个程序,结果如下图

 

posted @ 2021-08-26 22:02  粉尘  阅读(242)  评论(0)    收藏  举报