Ubantu下的GCC和MAKAFILE的初级使用
Ubuntu系统下用C语言编写一个简单的输出 hello word的程序
#include<stdio.h>
int main()
{
printf("hello world");
return 0;
}
gcc test1.c -o hello
编写一个主程序文件 main1.c 和一个子程序文件 sub1.h并用gcc运行
sub1.h
#include<stdio.h>
float x2x(int a,int b)
{
float x;
x=a+b;
return x;
}
main1.c
#include<stdio.h>
#include"sub1.h"
int main()
{
int a,b;
float y;
a=6,b=9;
y=x2x(a,b);
printf("%f",y);
return 0;
}
在windows环境下运行main1.c
用makefile的方式编译主程序main1.c