Hungarian Notation
Variable names should begin with the prefix shown in the table below.
Prefix | Type |
a | array |
b | bool (int) |
by | unsigned char (byte) |
ch | char |
cb | count of bytes |
cr | color reference value |
cx, cy | short (count of x, y length) |
dw | unsigned long (dword) |
f | float |
fn | function |
h | handle |
I | integer |
m_ | data member of a class |
n | short or int |
np | near pointer |
p | pointer |
l | long |
lp | long pointer |
str | string |
sz | string terminated with a zero |
tm | text metric |
w | unsigned int (word) |
x, y | short (x or y coordinate) |
In addition variables should be named so that it is obvious what they represent.
An example of this is if a variable is used to represent the total of apples currently in a shop it should (for instance) be called nNumberOfApplesInShop and not simply n1.
Examples :
pFirstName - a pointer to a value related to a first name.
chMaleOrFemale - a character signifying male or female.
m_strBookTitle - a string which is a member variable of a class.
Click here to return to homepage