C代码中的命名方式总结和改进

  1. 宏全部使用大写字母--------宏大写
  2. 结构体名字全部使用typedef,typedef之后的名字为大写-------结构体别名大写
  3. 函数名全部使用小写字母,单词之间使用下划线分割-------函数名小写,单词之间下划线(1)
  4. 函数名第一个单词全小写,后面单词的首字母大写,单词之间使用下划线---------函数名首单词小写,后面单词首字母大写(2)
  5. 变量名也是全部使用小写,单词之间使用下划线分割-------变量名小写,单词之间下划线(1)
  6. 变量名第一个单词全小写,后面单词的首字母大写,单词之间使用下划线---------变量名单词小写,后面单词首字母大写(2)

变量的命名前后缀规则如下(这是匈牙利命名法的前后缀格式,以后其他地方使用上述的总结,前后缀使用匈牙利的):

The type prefix indicates the data type of the variable.

Type prefixMeaningExample
bbooleanbool bHasEffect;
c (or none*)classCreature cMonster;
chchar (used as a char)char chLetterGrade;
ddouble, long doubledouble dPi;
eenumColor eColor;
ffloatfloat fPercent;
nshort, int, long
char used as an integer
int nValue;
sstructRectangle sRect;
strC++ stringstd::string strName;
szNull-terminated stringchar szName[20];

The following type modifiers are placed before the prefix if they apply:

Type modifierMeaningExample
aarray on stackint anValue[10];
ppointerint* pnValue;
padynamic arrayint* panValue = new int[10];
rreferenceint rnValue;
uunsignedunsigned int unValue;

The following scope modifiers are placed before the type modifier if they apply:

Scope modifierMeaningExample
g_global variableint g_nGlobalValue;
m_member of classint m_nMemberValue;
s_static member of classint s_nValue;

补充:

  • p ---------for a pointer. A pfoo would be a pointer to data item of type FOO
  • pp------- for a pointer to a pointer.
  • h --------for a heap handle. This is a pointer to a pointer that points at a data item recorded within a heap.
  • rg -------for an unstructured array containing data items of a certain data type. An rgfoo would be an array that contains data of type foo. Individual elements would be selected by an ifoo index variable.
  • mp -------for an array which is used to map from one data type to another.Eg. A mpdochdod would be indexed via a doc index. The expression mpdochdod[doc] would produce a handle to a document descriptor.
  • dn-------- for an array whose elements that describes a meaningful index such as an opcode. If the meaningful index were an OP type, a data structure of type EOP (entries for OP) would be defined, and a dnop array would be defined which describes what each individual op means

Max - added to an index data instance which records the actual size of an array or data block.
eg. the declaration of a an array of type FOO in C would be:
FOO rgfoo[ifooMax];

Mac - added to an index data instance to indicate the limit of an actual usage within an array.Mac stands for current maximum. It is invariant that ifooMac <= ifooMax. ifooMac == ifooMax is the condition which is true when all entries within an array are in use.

First - added to an index or pointer which designates the first element within a range that may be validly processed

Last - added to an index or pointer which designates that last entry within a range that may be validly processed.

Lim - stands for limit. An ifooLim is equal to ifooLast + 1 and designates the location where a new foo item could be recorded in an array or data block.



转载于:https://www.cnblogs.com/jack204/archive/2011/09/07/2170408.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/267600.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

linux 安装软件的几种方法

一、 解析Linux应用软件安装包&#xff1a;通常Linux应用软件的安装包有三种&#xff1a;1&#xff09; tar包&#xff0c;如software-1.2.3-1.tar.gz。它是使用UNIX系统的打包工具tar打包的。2&#xff09; rpm包&#xff0c;如software-1.2.3-1.i386.rpm。它是Redhat Linux提…

对计算机网络用户而言 掌握网络,计算机网络的特点

1、可靠性在一个网络系统中&#xff0c;当一台计算机出现故障时&#xff0c;可立即由系统中的另一台计算机来代替其完成所承担的任务。同样&#xff0c;当网络的一条链路出了故障时可选择其它的通信链路进行连接。2、高效性计算机网络系统摆脱了中心计算机控制结构数据传输的局…

Bootstrap-CSS:表格

ylbtech-Bootstrap-CSS&#xff1a;表格1.返回顶部 1、Bootstrap 表格 Bootstrap 提供了一个清晰的创建表格的布局。下表列出了 Bootstrap 支持的一些表格元素&#xff1a; 标签描述<table>为表格添加基础样式。<thead>表格标题行的容器元素&#xff08;<tr>…

Oracle找出需要建立索引的表

文章讨论的是本来应该建立索引而因为疏忽&#xff0c;或者考虑不周全而没有建立的情况 select distinct sp.OBJECT_NAME,round(ds.bytes/1024/1024,2) MB,num_rows,last_analyzed from v$sql_plan sp ,v$sqlarea sq,dba_segments ds,dba_tables dt where sq.ADDRESSsp.ADDRESS …

石油采集(求联通区域) 2018多校寒假集训 (dfs+二分匹配)

题目&#xff1a; 链接&#xff1a;https://www.nowcoder.com/acm/contest/76/A来源&#xff1a;牛客网 随着海上运输石油泄漏的问题&#xff0c;一个新的有利可图的行业正在诞生&#xff0c;那就是撇油行业。如今&#xff0c;在墨西哥湾漂浮的大量石油&#xff0c;吸引了许多商…

Struts1 处理接收参数插入到数据库之后呈乱码的问题解决

Struts处理接收参数乱码问题&#xff08;actionForm接受的参数发送至数据库成乱码&#xff09;的解决办法: 第一步&#xff1a; 新建一个类如&#xff1a;EncodingActionServlet 继承 ActionServlet 覆盖父类process()方法代码如下&#xff1a;package com.aptech.jb.epet.we…

计算机nit题百度云,计算机NIT应用基础试题

一、 填空题(25分)文章地址&#xff1a;https://www.llysc.cn/content/24-24873.html1、完整的计算机由硬件系统 和软件系统 两大部件组成的。3、存储器可分为内存储器 和外存储器 两类。4、微型计算机硬件系统一般应包括主机、键盘、鼠标和显示器 。5、通过鼠标的基本操作方法…

前端(2)CSS

css&#xff1a;Cascading Style Sheet 层叠样式表——修饰、美化网页&#xff0c;化妆师CSS优先级&#xff0c;即是指CSS样式在浏览器中被解析的先后顺序。行间样式 > 内嵌css样式 > 外链css样式&#xff08;在style之前引入&#xff09;如果外链css样式在style之后引入…

某计算机公司的库存管理,《管理系统中计算机应用》应用题数据流程图汇总题及参考答案...

《管理系统中计算机应用》应用题及参考答案——数据流程图1、教学管理的主要工作过程是&#xff1a;系办(公室)输入班级和教学时间&#xff0c;查看教学计划表&#xff0c;确定本学期教学任务&#xff1b;根据本学期教学任务&#xff0c;查看教师表&#xff0c;制作开课任务书和…

perl命令行参数

查看perl版本 perl -version 对脚本进行语法检查 perl -c scriptname.pl&#xff0c;比如 perl -c zdd.pl对zdd.pl进行语法检查&#xff0c;并不执行。 调试perl脚本 perl -d script.pl 执行命令 perl -e print "hellow, world!\n" 注意&#xff0c;在Windows上-e后面…

Missing artifact net.sf.json-lib:json-lib:jar:2.4错误和Eclipse安装Maven插件错误

微信公众号&#xff1a;compassblog 欢迎关注、转发&#xff0c;互相学习&#xff0c;共同进步&#xff01; 有任何问题&#xff0c;请后台留言联系&#xff01; 1、配置Maven项目的pom.xml文件报错 &#xff08;1&#xff09;、错误描述&#xff1a;Missing artifact net.sf.j…

C linux Debug

1 gcc -g -o dest source.c gdb dest //执行可执行文件并DEBUG b 5 // 设计第五行为断点 run //运行程序 l //下一步 p //打印 s //跳入函数并下一步 转载于:https://www.cnblogs.com/lovemo1314/archive/2011/09/19/2181793.html

bzoj千题计划241:bzoj3864: Hero meet devil

http://www.lydsy.com/JudgeOnline/problem.php?id3864 题意&#xff1a; 给你一个DNA序列&#xff0c;求有多少个长度为m的DNA序列和给定序列的LCS为0&#xff0c;1&#xff0c;2.... 求LCS方式&#xff1a;f[i][j]max&#xff08;f[i-1][j],f[i][j-1],f[i-1][j-1]*(s[i]t[j]…

计算机网络工程本科培养计划,网络工程专业卓越计划本科培养方案2015版-西安电子科技大学计算机.doc...

网络工程专业卓越计划本科培养方案2015版-西安电子科技大学计算机.doc网络工程专业卓越计划本科培养方案一、培养目标及培养模式(一)培养目标网络工程专业培养服务于社会主义现代化建设需要的德、智、体、美全面发展&#xff0c;较好的掌握工科公共基础知识&#xff0c;系统地掌…

Apache日志配置

有时候我们需要定制Apache默认日志的格式和内容&#xff0c;比如增加或减少日志所记录的信息、改变默认日志文件的格式等。本文介绍可以用日志 记录的所有信息&#xff0c;以及如何设置Apache使其记录这些信息。    一、定义日志格式(4月3日) 很久以前&#xff0c;日志文件…

web前端【补充】CSS补充

css常用的一些属性&#xff1a; 1.去掉下划线 &#xff1a;text-decoration:none ;2.加上下划线&#xff1a; text-decoration: underline; 3.调整文本和图片的位置&#xff08;也就是设置元素的垂直对齐方式&#xff09;&#xff1a;vertical-align:-20px; 没设置之前&#xf…

语言教案 小小计算机,小班《小小手机本领大》语言教案

【活动目标】1、认识各种手机&#xff0c;了解手机的变化史。2、探索手机的秘密&#xff0c;知道手机的使用方法。【活动准备】各类手机。【活动过程】一、谈话引出课题。星期天你和妈妈去公园&#xff0c;不小心和妈妈走散了&#xff0c;小朋友们有什么办法能找到妈妈&#xf…

XNA游戏:Hello XNA

下面创建一个简单的Windows Phone 7的XNA 程序&#xff0c;只是一个Hello XNA的文本&#xff0c;从屏幕的左上角一直往右下角移动&#xff0c;通过该例子来开始Windows Phone 7 XNA的游戏编程。 新建一个项目后可以看到这样的一个项目工程结构&#xff0c;如图所示。 Content项…

最快超级计算机神威,我国超算第一不保, 2018年最快超级计算机超神威太湖之光2倍...

原标题&#xff1a;我国超算第一不保, 2018年最快超级计算机超神威太湖之光2倍计算机的进化可以说是日新月异&#xff0c;去年的我国的神威太湖之光与天河二号分别为全球最快的大型计算机榜单第一和第二名。但是2018年新的超级计算机性能排名又出来了&#xff0c;这次我国的神威…

Website for the introduction to Matlab and Java

http://www.aquaphoenix.com/#Lectures转载于:https://www.cnblogs.com/stoneresearch/archive/2011/09/21/4336541.html