龙空技术网

变量命名实用技巧你收藏夹有吗?

IT三宝 92

前言:

现在同学们对“c语言 变量命名规则”大约比较关注,大家都需要了解一些“c语言 变量命名规则”的相关文章。那么小编也在网上网罗了一些有关“c语言 变量命名规则””的相关内容,希望同学们能喜欢,大家一起来了解一下吧!

命名的基本原则

(1)标识符的命名要清晰、明了,有明确含义,同时使用完整的单词或大家基本可以理解的缩写,避免使人产生误解——尽量采用采用英文单词或全部中文全拼表示,若出现英文单词和中文混合定义时,使用连字符“_”将英文与中文割开。较短的单词可通过去掉“元音”形成缩写;较长的单词可取单词的头几个字母形成缩写;一些单词有大家公认的缩写。例如:temp->tmp、flag->flg、statistic->stat、increment->inc、message->msg等缩写能够被大家基本认可。

(2)命名中若使用特殊约定或缩写,则要有注释说明。应该在源文件的开始之处,对文件中所使用的缩写或约定,特别是特殊的缩写,进行必要的注释说明。

(3)命名规范必须与所使用的系统风格保持一致,并在同一项目中统一。

(4)对于变量命名,禁止取单个字符(如i 、j 、k... ),建议除了要有具体含义外,还能表明其变量类型、数据类型等,但i 、j 、k 作局部循环变量是允许的。变量,尤其是局部变量,如果用单个字符表示,很容易敲错(如i写成j),而编译时又检查不出来,有可能为了这个小小的错误而花费大量的查错时间。

编程单词缩写字典

序号

描述

缩写词

A

Addition

Add

Accumulator

Acc

Address

Addr

Action

Act

Active

Act

Amplitude

Amp

Analog Input

AI

Anolog I/O

AIO

All

All

Alarm

Alm

Allocate

Alloc

Analog Output

AO

Apparent

App

Argument

Arg

Arrange

Arrng

Array

Array

Assemble

Asm

Attribute

Attrib

B

Bar

Bar

Bit

Bit

Block

Blk

Buffer

Buf

Button

Btn

Bypass

Bypass

C

Calibration

Cal

Calculate

Calc

Configuration

Cfg

Channel

Ch

Change

Chg

Check

Chk

Clock

Clk

Clear

Clr

Clear Screen

Cls

Command

Cmd

Compare

Cmp

Complete

Comp

Count

Cnt

Counter

Ctr

Column

Col

Communication

Comm

Connect

Con

Construct

Cons

Control

Ctrl

Context

Ctx

Convert

Conv

Copy

Cp

Current

Cur

Cursor

Csr

Control Word

CW

D

Date

Date

Day

Day

Debounce

Debounce

Decrease

Dec

Decimal

Dec

Decode

Decode

Define

Def

Degree

Deg

Delete

Del

Destination

Dst

Descriptor

Desc

Device

Dev

Discrete Input

DI

Digit

Dig

Discrete I/O

DIO

Discrete Output(s)

DO

Disable

Dis

Display

Disp

Discovery

Disc

Division

Div

Divisor/Division

Div

Delay

Dly

Day-of-week

DOW

Down

Down

Dummy

Dummy

Dynamic

Dyn

E

Edge

Edge

Effective

Eff

Electric

Elec

Empty

Empty

Enable

En

Engine

Eng

Enter

Enter

Entries

Entries

Equivalent

Equiv

Error(s)

Err

Ethernet

Eth

Engineering Units

EU

Event(s)

Event

Extension

Ext

Exit

Exit

Exception

Exc

Expiration

Exp

Exponent

Exp

F

Field

Fld

Flag

Flag

Flush

Flush

Function(s)

Fnct

Format

Format

Fraction

Fract

Free

Free

Frequency

Freq

Full

Full

G

Gain

Gain

Get

Get

Generate

Gen

Group(s)

Grp

H

Handler

Handler

Harmonic

Harm

Hexadecimal

Hex

High

Hi

History

Hist

Hit

Hit

High Priority Task

HPT

Hour(s)

Hr

I

I.D.

Id

Idle

Idle

Impulse

Imp

Input(s)

In

Initialization

Init

Initialize

Init

Instruction

Instr

Interrupt

Int

Invert

Inv

Interrupt Service Routine

ISR

Index

Ix

K

Key

Key

Keyboard

Key

L

Length

Len

Limit

Lim

List

List

Low

Lo

Lower

Le

Lowest

Lo

Lock

Lock

Low Priority Task

LTP

M

Magnitude

Mag

Mantissa

Man

Manual

Man

Manufacture

Mfg

Maximum

Max

Mailbox

Mbox

Minimum

Min

Mode

Mode

Month

Month

Move

Mov

Message

Msg

Measure

Meas

Mask

Msk

Multiplication

Mul

Multiplex

Mux

Make

Mk

N

Negative

Neg

Number of

Num

Nesting

Nesting

Neutral

Neut

New

New

Next

Next

O

Offset

Offset

Old

Old

Operation System

OS

Optimize

Opt

Original

Orig

Output

Out

Overflow

Ovf

P

Package

Pkg

Parameter

Param

Pass

Pass

Performance

Perf

Period

Per

Phase

Ph

Port

Port

Position

Pos

Positive

Pos

Power

Pwr

Previous

Prev

Priority

Prio

Printer

Prt

process

Proc

Product

Prod

Protocol

Prot

Pointer

Ptr

Put

Put

Q

Queue

Q

Quality

Qlty

Quarter

Quar

R

Raw

Raw

Reactive

React

Recall

Rcl

Rectangle

Rect

Read

Rd

Ready

Rdy

Reference

Ref

Register

Reg

Request

Req

Reset

Reset

Reserve

Resv

Resume

Resume

Response

Resp

Return

Rtn

Reverse

Revs

Ring

Ring

Row

Row

Repeat

Rpt

Real-Time

RT

Running

Running

Receive

Rx

S

Sample

Smp

Scale

Scale

Scale Factor

SF

Scaling

Scaling

Scan

Scan

Schedule

Sched

Scheduler

Sched

Screen

Scr

Second(s)

Sec

Segment(s)

Seg

Select

Sel

Semaphore

Sem

Sequence

Seq

Server

Svr

Set

Set

Setting

Setting

Signal

Sig

Size

Size

Seven-segments

SS

Sourse

Src

Start

Start

Statistic(s)

Stat

Status

Stat

Stack

Stk

Standard

Std

Stop

Stop

String

Str

Subtraction

Sub

Suspend

Suspend

Switch

Sw

Synchronize

Synch

System

Syst

T

Task

Task

Table

Tbl

Threshold

Th

Tick

Tick

Time

Time

Timer

Tmr

Toggle

Tgl

Total

Tot

Trigger

Trig

Time-stamp

TS

Timeout

TO

U

Unlock

Unlock

Up

Up

Update

Update

Utility

Util

V

Value

Val

Vector

Vect

Version

Ver

Variable

Var

Visible

Vis

Voltage

Vol

W

Watchdog

Wdog

Write

Wr

Y

Year

Year

python基础

Python+大数据开发自学教程_Python+大数据开发视频教程从入门到精通_黑马程序员

Python 入门教程完整版(全 547 集)Python 进阶之 MySQL 入门教程Python 深入浅出进阶课程2 小时玩转 Python 多线程编程人工智能:Python 3 天快速入门机器学习项目Python 深度学习之神经网络爬虫:Python 爬虫入门:180 分钟轻松获取疫情数据

以上希望对你有一点帮助。有用可以收藏哦

标签: #c语言 变量命名规则