Constants
ANSI C allows you to declare constants. When you declare a constant it is a bit like a variable declaration except the value cannot be changed.
The const keyword is to declare a constant, as shown below:
int const a = 1;
const int a =2;
Note:
You can declare the const before or after the type. Choose one an stick to it.
It is usual to initialise a const with a value as it cannot get a value any other way.
The preprocessor #define is another more flexible (see Preprocessor Chapters) method to define constants in a program.
You frequently see const declaration in function parameters. This says simply that the function is not going to change the value of the parameter.
The following function definition used concepts we have not met (see chapters on functions, strings, pointers, and standard libraries) but for completenes of this section it is is included here:
void strcpy(char *buffer, char const *string)
The second argiment string is a C string that will not be altered by the string copying standard library function.
Thursday, November 6, 2008
what r constants ??
Posted by Deeptisoftwares Welcomes You at 10:28 PM
Subscribe to:
Post Comments (Atom)

0 Comments:
Post a Comment