头文件 singnext.dingswords

printf("终止我每丝呼吸,让心灵穿透所有的秘密\n");

头文件 singtocj.h

printf("当无数的日月沧桑后,你会在谁身旁?\n");

头文件 myhead.h

#include <stdio.h>
#include <Windows.h> int a = ;
int b = ;

头文件 calresult.h

# include "myhead.h"

float c;
c = (a + b)*0.035;

主程序文件

#include <stdio.h>
#include <Windows.h> void main()
{
#include "singnext.dingswords"
#include "singtocj.h"
//#include "myhead.h"
#include "calresult.h"
printf("小烤肠快回来吧,老张决定这个月发你工资%d,另外还有你比赛夺冠的奖金%d\n", a, b);
printf("共计%d\n", a+b);
printf("另外还有%f元努力训练奖励\n", c);
getchar();
}

点评,以上代码显示了头文件(xx.h)文件的调用,这很像python from xx.py import xxx的模块调用过程。需要注意的是头文件貌似不支持自定义函数;声明 #include “你定义的头文件”可以出现在程序文件的任何位置,就像主程序文件使用的那样。

头文件和主程序文件部署目录如下图:

运行结果

陷阱:头文件重复引用

假如对主程序文件作如下更改----第8行引入头文件myhead.h:

 #include <stdio.h>
#include <Windows.h> void main()
{
#include "singnext.dingswords"
#include "singtocj.h"
#include "myhead.h"
#include "calresult.h"
printf("小烤肠快回来吧,老张决定这个月发你工资%d,另外还有你比赛夺冠的奖金%d\n", a, b);
printf("共计%d\n", a+b);
printf("另外还有%f元努力训练奖励\n", c);
getchar();
}

则会报错提示多次初始化,其原因在于calresult.h引入了myhead.h主程序再次引用构成了对文件中变量的多次引用!解决方案是注释掉上述代码第8行

最新文章

  1. ORB-SLAM(六)回环检测
  2. Linux system log avahi-daemon[3733]: Invalid query packet
  3. 黄聪:远程序桌面登录的.NET(C#)开发
  4. Java--剑指offer(8)
  5. [原创]java WEB学习笔记55:Struts2学习之路---详解struts2 中 Action,如何访问web 资源,解耦方式(使用 ActionContext,实现 XxxAware 接口),耦合方式(通过ServletActionContext,通过实现 ServletRequestAware, ServletContextAware 等接口的方式)
  6. 在PHP中如何获取用户的真实IP
  7. 【译】 AWK教程指南 11递归程序
  8. css考核点整理(九)-有几种文字替换方式,之间的优缺点
  9. 禁用USB存储设备(不重启)
  10. CSS3动画之旋转魔方盒
  11. 成都传智播客JDBC视频及讲师介绍
  12. FineUIMvc
  13. IOS Swift语言开发 tableView的重用以及自cell的自适应高度
  14. transition-timing-function 属性
  15. 关于RecyclerView嵌套导致item复用异常,界面异常的问题
  16. 15 Django REST Framework 给api添加自定义搜索条件
  17. centos6.5配置redis服务 很好用谢谢
  18. Spring Core Programming(Spring核心编程) - AOP Concepts(AOP基本概念)
  19. 浅谈MVVM
  20. 使用plumbing命令来深入理解git add和git commit的工作原理

热门文章

  1. Linux命令中dd的作用
  2. ARC083E. Bichrome Tree
  3. (八)Spring 事务管理
  4. B - How many integers can you find
  5. 小白学PYTHON时最容易犯的6个错误
  6. MySQL的安装 --windows版本
  7. 维护solr索引库
  8. VBA学习资料分享-2
  9. paramiko模块实现远程传输控制
  10. java获取类的3种方式