目录
一.使用gcc编译c程序
(一)编写main1.c
#include"sub1.h"
int main()
{
int x=4,y=9;
printf("%.2f\n",x2x(x,y));
return 0;
}
(二)编写sub1.h
#ifndef _SUB1_H
#define _SUB1_H
#include<stdio.h>
float x2x(int a,int b);
#endif
(三)编写sub1.c
#include"sub1.h"
float x2x(int a,int b)
{
float ans;
ans=(float)b/a;
return ans;
}
(四)用gcc编译
首先打开终端,输入
gedit main1.c