How to assign a pointer to a variable?

Suppose we have a variable kequal to 7:

int k=7;
int t=&k;

But that does not work. What mistake?

+3
source share
3 answers

&ktakes the address k. You probably mean

int *t = &k;

I have a good reading for you: The Alpha P. Steinbach Guidebook .

+3
source

You probably meant:

int k=7;
int *t=&k;
+7
source

t int int*. int* int, , . : declar t int*. , , , , - .

+1
source

Source: https://habr.com/ru/post/1753303/


All Articles