C语言自己编写头文件

C语言自己编写头文件

1. 首先编写head.h

1 #ifdef _HEAD_H

2 #define _HEAD_H

3 int add(int,int,int);

4 #endif2. 在同级目录下编写head.c

1 #include "head.h"

2 #include

3 int add(int a,int b,int c)

4 {

5 int result = 0;

6 printf("%s","Please enter the number:");

7 scanf("%d %d %d",&a,&b,&c);

8 result = a+b+c;

9 return result;

10 }3. 编写hello.c

1 #include

2 #include "head.h"

3 void main()

4 {

5 int a=3,b=4,c=5,result=0;

6 result=add(a,b,c);

7 printf("The result is %d!",result);

8 }4. 将hello.c与head.c通过gcc命令编译起来

gcc -o cal hello.c head.c5. 执行可执行文件

./cal

相关推荐

藤的意思,藤的解释,藤的拼音,藤的部首,藤的笔顺
365bet官网中文网

藤的意思,藤的解释,藤的拼音,藤的部首,藤的笔顺

⏱️ 08-13 👁️ 4871
长时间盯着电脑会头晕
bt365无法登陆

长时间盯着电脑会头晕

⏱️ 08-03 👁️ 9467
ios用什么软件接单代练 最靠谱的苹果代练平台推荐
体育投注英超和欧冠

ios用什么软件接单代练 最靠谱的苹果代练平台推荐

⏱️ 09-06 👁️ 7335
衔的英文
365bet官网中文网

衔的英文

⏱️ 08-01 👁️ 4945
龙骑士 莫德凯撒 [520 RP]
bt365无法登陆

龙骑士 莫德凯撒 [520 RP]

⏱️ 10-02 👁️ 4578
巧剁肉泥的做法
bt365无法登陆

巧剁肉泥的做法

⏱️ 09-25 👁️ 400