C语言命名规范

https://www.cnblogs.com/wfwenchao/p/5209197.html

正义 反义
add remove
begin end
create destroy
insert delete
first last
g et release
increment decrement
put get
add delete
lock unlock
open close
min max
start stop
next previous
source target
show hide
send receive
source destination
cut paste
up down

变量名

 变量的命名规则要求用匈牙利法则

即开头字母用变量的类型,其余部分用变量的英文意思、英文的缩写、中文全拼或中文全拼的缩写,要求单词的第一个字母应大写。

即: 变量名=变量类型+变量的英文意思(或英文缩写、中文全拼、中文全拼缩写)

对非通用的变量,在定义时加入注释说明,变量定义尽量可能放在函数的开始处。

类型 其他 规则 举例
int $1600
short int centered $12
long int are neat $1

- int 用i开头 iCount
- short int 用n开头 nStepCount
- long int 用l开头 lSum
- char 用c开头 cCount
- unsigned char 用by开头
- float 用f开头 fAvg
- double 用d开头 dDeta
- unsigned int(WORD) 用w开头 wCount
- unsigned long int(DWORD) 用dw开头 dwBroad
- 字符串 用s开头 sFileName
- 用0结尾的字符串 用sz开头 szFileName

函数名

其他

(6)对struct、union变量的命名要求定义的类型用大写。并要加上前缀,其内部变量的命名规则与变量命名规则一致。

结构一般用S开头,如:
struct ScmNPoint
{
int nX;//点的X位置
int nY; //点的Y位置
};

联合体一般用U开头,如:
union UcmLPoint
{
LONG lX;
LONG lY;
}

你可能感兴趣的:(C语言命名规范)