Friday, April 6, 2012

Change value of a variable with out using pointer

Ques: Change value of a variable with out using pointer.
Boundary conditions
can only initalise the variable (variable whose value we want to change)and address operation can only be performed (&variable_name)
cannot use pointers variable.

here is an simple program
#include<conio.h>
 #include<stdio.h>
 int main(int argc, char *argv[])
 {
 int var=5,vptr;/*virtual pointer vptr*/
 clrscr();
 printf("value before operation:%d",var);
 vptr=(int)&var;
 *(int *)vptr=10;
 printf("value after operation:%d",var);
 getchar();
 return 0;
 }
its simple just use the type conversion trick.
thank you.bye.

Labels: , , , , , ,

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

Links to this post:

Create a Link

<< Home