Difficulty in understanding c pointers when it is on it

I study pointers to c and this placement *really bothers me.

I understand that int *athere is ..

But what is

a = malloc(n * sizeof(int) ) 

I understand that the above, but why *in the middle of itself ??? Does this part really bother me, please can someone explain to me?

+4
source share
6 answers

*here it is very simple and, paradoxically, you will not be difficult to understand until you have learned about pointers. Now, C's deliberately confusing syntax is just misleading.

* . n int, , n ints

, , a = b * c . : a=*b (* b).

+3

* * .

+5

* . * .
, -.

+4

* ,

int b=10;
int *a = &b;

*a , *

int c = b * 10;

* , *

+1

. 5*5 25. int *a; a, a*a a a.

0

. *, ( ..) - ( ..) , , "" ( ..). . :

int *a = 1  

:

a = b + *c

Please note that in the last example, we have a variable in front of *, but not directly in front of, there is a plus sign ( +) in the middle.

But if you have a variable (or etc.) right before *it is a binary operator, it "affects" two variables (or etc.).

a = b * *c

See, here I use both of them. I assign a value b times that c points to.

Hope this helps you better understand.

0
source

All Articles