基于VMware软件和Ubuntu系统的gcc、Makefile编译C程序
1 Ubuntu系统下的C程序编译
1.1 编写C程序:输出“hello world!"
#include<stdio.h>
int main()
{
printf("hello world!\n");
return 0;
}
1.1.1 用gcc编译C程序(hello.c)
1.用vim命令编写程序:输入vim hello.c
2.用gcc命令编译程序:输入gcc hello.c -o hello
3.运行:输入./hello
4.输出结果
1.2 编写C程序:一个主程序文件 main.c 和一个子程序文件 sub.c
要求:请编写一个主程序文件 main1.c 和一个子程序文件 sub1.c, 要求:子程序sub1.c 包含一个算术运算函数 float x2x(int a,int b),此函数功能为对两个输入整型参数做某个运算,将结果做浮点数返回;主程序main1.c,定义并赋值两整型变量,然后调用函数 x2x,将x2x的返回结果printf出来。