1、安装GCC
ubuntu@ubuntu-VirtualBox:~/桌面$ sudo apt-get install build-essential
2、用c编写“Hello world”程序:
第一步:vi创建 hello.c
ubuntu@ubuntu-VirtualBox:/home$ sudo vi hello.c
第二步:为hello.c输入以下内容
#include "stdio.h" // 标准输入输出库的头文件
main() // main是固定名称,用于标记程序的执行入口
{
printf("Hello world!你好,Ubuntu!\n"); // printf是系统输出函数,用于向控制台打印文字。
}
3、编译程序。执行命令:
ubuntu@ubuntu-VirtualBox:/home$ sudo gcc -o hello hello.c
4、执行程序,也就是运行程序。输入命令:
ubuntu@ubuntu-VirtualBox:/home$ ./hello
总结:
到此为止,在ubuntu上编写第一个“Hello world”C程序就算成功了。
远程技术指导QQ:31504758 (野龖 )
您的支持就是我们前进的动力,感谢您的支持及鼓励。