Tuesday, October 27, 2009

Constant Number:

is't possible to change the constant number in c program? ofcourse not, if you try to change the value it will error msg as "can't modify a const object in function main". But we can change const value using pointer variable.

#include < stdio.h >
void main()
{
const a=10;
int *p=&a;
*p=20;
printf("%d",a);
}

output:
20

we can change the constant variable value using pointer. it'll show only one warning i.e., "Suspicious pointer conversion in function main.

0 comments:

Post a Comment