C Programming

MORE ABOUT VARIABLES
Variables must begin with a character or underscore, and may be followed by any combination of characters, underscores, or the digits 0 - 9. The following is a list of valid variable names,


	summary
	exit_flag
	i
	Jerry7
	Number_of_moves
	_valid_flag

You should ensure that you use meaningful names for your variables. The reasons for this are,


CLASS EXERCISE C3
Why are the variables in the following list invalid,


	value$sum
	exit flag
	3lotsofmoney
	char

Answers


VARIABLE NAMES AND PREFIXES WHEN WRITING WINDOWS OR OS/2 PROGRAMS
During the development of OS/2, it became common to add prefix letters to variable names to indicate the data type of variables.

This enabled programmers to identify the data type of the variable without looking at its declaration, thus they could easily check to see if they were performing the correct operations on the data type and hopefully, reduce the number of errors.

	Prefix		Purpose or Type
	b		a byte value
	c		count or size
	clr		a variable that holds a color
	f		bitfields or flags
	h		a handle
	hwnd		a window handle
	id		an identity
	l		a long integer
	msg		a message
	P		a Pointer
	rc		return value
	s		short integer
	ul		unsigned long integer
	us		unsigned short integer
	sz		a null terminated string variable
	psz		a pointer to a null terminated string variable	

In viewing code written for Windows or OS/2, you may see variables written according to this convention.


©Copyright B Brown. 1984-1999. All rights reserved.