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?
CS50 Stack Exchange is a question and answer site for students of Harvard University's CS50. It only takes a minute to sign up.
Sign up to join this communityFirst 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