`
zhangjia328
  • 浏览: 17940 次
  • 性别: Icon_minigender_1
  • 来自: 北京
最近访客 更多访客>>
社区版块
存档分类
最新评论

Knowledge Points

    博客分类:
  • C
阅读更多

1. Turbo C 2.0 工程文件下各模块相互通信

(1) 同一个工程下的不同.c文件包含相同的头文件时,比如my.h,则在my.h中,不能定义变量,因为此处定义的变量具有全局作用域,导致编译时出现重定义错误。但可以定义常量,比如 #define PI 3.14 因为,该编译预处理只是在所在的.c文件中进行宏替换,不会引起命名上的冲突。

(2) 同一个工程下的不同.c文件可以通过共享变量或数组进行通信。变量不仅包括char, int, long等基本类型的变量,还可以是union, struct 这些自定义类型的变量。

当共享自定义类型变量时,自定义类型的说明应包含在一个头文件中,然后在共享该自定义类型变量的.c文件中包含该头文件。 类似,共享数组的元素类型可以是基本类型或者自定义类型,而且共享自定义类型数组的.c文件要包含一个头文件,该头文件包含了自定义类型的说明。 与基本类型变量相同,自定义类型变量和数组的引用性声明的存储类型为extern,而定义性声明可以在定义时进行初始化,或者不写存储类型extern

2. sizeof

MS-DOS中,sizeof的计算方法:

a为数组:sizeof(a)的结果为 数组长度*元素所占字节数

a为指针:sizeof(a) = 2 DOS中的偏移地址是16位,所以指针类型的大小为2个字节 aint sizeof(a) = 2 or 4, 与具体机器相关

3. scanf()

输入时 单精度 双精度 的区别 下面是示例代码:  

  float fa, fb; printf("input two float : "); scanf("%f %lf", &fa, &fb); printf("\n%f %f\n", fa, fb); // 打印出的 fa 为错误的值, fb = 0 double da, db; printf("input two double : "); scanf("%f %lf", &da, &db); printf("\n%f %f\n", da, db); // 打印出的 da = 0, db 为正确的值。



 

解释: scanf("%f %lf", &fa, &fb) 中,%f 对应于单精度浮点数,scanf() fa 解释为 float 类型, %lf 对应于 double 类型,所以,scanf() fb 解释为 double 类型。scanf() fb 的隐式的类型转换(从 float 转换为 double)扩展了存储单元的位数,可能会影响其他变量,从而导致 fa 的输出值错误。printf() 输出 fa fb 时按 float 类型进行解释,所以,fb 的输出值也错误。 scanf("%f %lf", &da, &db) 中,scanf() da 隐式的类型转换没有扩展存储单元的位数,所以 不会影响 db ,所以 db 的输出值正确。同样道理,printf() 输出 da db 时按 double 类型进行解释,所以,da 的输出值错误。

 

4. C/C++ 中的目录字符串

 

char * dir1 = "C:sub1sub2some1.txt"; char * dir2 = "C:\sub1\sub2\some2.txt"; char * dir3 = "C:/sub1/sub2/some3.txt"; fopen(dir1, "w"); fopen(dir2, "w"); fopen(dir3, "w");


 

在上面的例子中,dir1 是不合法的,因为 C/C++ 中的函数对路径字符串处理时,会按照格式字符串进行处理,dir1dir2中第一个''是转义字符。所以无法正确的解析 dir1 所表示的路径。dir2 dir3 均合法,能被正确的解析。dir3 我原以为是 linux 下的写法,但实际上在 Windows 上也是正确的,而且比 dir3 更加简洁。 windows 平台上编译安装一些源代码包时(这些源代码包程序多是起源于 linux),在运行配置、编译命令时,有时需要输入文件名/路径名,这时需要注意,文件名/路径名必须是 dir2 或者 dir3 的格式,直接在 windows 窗口的地址栏中拷贝的文件名/路径名dir1 格式)会导致编译或连接出错。

 

分享到:
评论

相关推荐

    CPP.rar_Key Of Knowledge

    Key knowledge about C + +, A review of knowledge points.

    Java-knowledge-points-list.rar_Knowledge

    对于java的一些关键点的描述和讲解!! Java知识点列表

    C++培训材料

    this is a document that include C++ training ctritical knowledge points, it maybe a good resoure when you will face an interview which will need c++ skills.

    Computer Network Chapter1-5.docx

    基于 《计算机网络-软硬件接口》一书的知识点,全英文,五大层次...Based on the computer network - Hardware and Software interface book knowledge points, full English, five levels of detailed description.

    segment:分散的知识点

    Scattered knowledge points here. Maybe you can find something useful. 最近更新 JavaScript 新旧替换 工作流 Canvas Canvas 绘制 1 px 直线模糊(非高清屏)的问题 Canvas 橡皮擦效果 Canvas 图像灰度处理 ...

    阿里云java短信验证码源码-Full-Stack-Engineer-Study-Map:这个知识库的目的是总结全栈工程师会遇到的知识点。这个

    knowledge points that full-stack engineers will encounter. This is mainly used to help me find a job. Login Bot Detection (没有绝对的安全,难度如巅峰的google的reCAPTCHA,也能被破解) 简单图形验证码 ...

    99乘法表java源码-j1st-note:笔记

    knowledge points Java development history: 2017年8月,JCP执行委员会提出将Java的发布频率改为每六个月一次,该决定将在Java 9正式发布之后开始实行 1990年初,最初被命名为Oak; 1995年5月23日,Java语言诞生 ...

    THUEE-Sophomore_Spring-Course_knowledge_points

    THUEE-Sophomore_Spring-Course_knowledge_points

    Ontologies: Silver Bullet for Knowledge Management and Electronic Commerce

    points into a world wide network of information exchange and business transactions called the World Wide Web (WWW). Therefore support in the exchange of data, information, and knowledge exchange is ...

    What is notch filter

    A closely related Knowledgebase item discusses the concept of the Q of a filter. This Knowledgebase item focuses on high Q notch filters - the type that eliminate a single frequency or narrow band ...

    CCNA_ALL_IN_ONE.pdf

    knowledge of CCNA hardware and software used in today’s computer world, and the certification is one of the most popular certifications for IT professionals to prove their hardware and software ...

    ACCA MA 教材

    Provide lots of exam focus points demonstrating what the examination will want you to do  Emphasise key points in regular fast forward summaries  Test your knowledge of what you've studied in ...

    An Invitation to 3D Vision Y. Ma, S. Soatto, J. Kosecka, S. Sas

    Multiview reconstruction from points and lines (lecture5.ppt) Multiview reconstruction with scene knowledge (lecture6.ppt) Step-by-Step model building (lecture8.ppt) Case study UAV's landing ...

    CCENT Certification All-In-One For Dummies.pdf

    your knowledge of basic Cisco device-management and networking concepts. It is a great stepping stone to the CCNA certification and other Cisco certification tracks. The CCENT exam tests your ...

    Just Enough Software Architecture: A Risk-Driven Approach

    It describes the techniques software designers use to reason about medium to large sized problems and points out where you can learn specialized techniques in more detail. It provides practical ...

    Horn_Antennas_Horn_srd_antenna_waveguideantenna_

    Beyond the fundamental knowledge of microwavepropagation it is essential in the design of horn antenna tounderstand the intricacies and design considerations at twoimportant ends: the points of ...

    PMI-ACP outline

    The content outline to help certificate exam takers quickly understand the scope and knowledge areas and the exam points allocation percentage. The reference is also very helpful.

    S. J. Wright Numerical Optimization(second edition).pdf

    Knowledge of the capabilities and limitations of these algorithms leads to a better understanding of their impact on various applications, and points the way to future research on improving and ...

    A taxonomy of dirty data

    In particular, we investigated empirically derived problems that emerge with different types of time-oriented data (e.g., time points, time intervals) and provide various examples of quality problems...

    Learn JavaScript with p5.js_Coding for Visual Learners-Apress(2018).pdf

    technical or theoretical points. The aim is to build a strong but a minimum viable knowledge to get you running with coding. This is the book that I wished I had available when I was learning coding...

Global site tag (gtag.js) - Google Analytics