0

e.g. Input:

int a = 1;
int b = a;

b = 5;

printf("%i \n", a);

Output:

5

I have tried writing things like

int* b = &a;
b = 5;

However i cant change b into an integer from a pointer?

0

First part was right, but second line would change the pointer, while you want to change the pointee.

int a = 1;         // a initialised to 1
int* b = &a;       // have b point to a
*b = 5;            // pointee of b (which is a) set to 5
printf("%i\n", a); // prints 5

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .