0

What is the differences between declaring int* p; and int *p;

in some program i found int* p; and in other int *p; why?

13th Jan 2020, 10:37 AM
Andrea Pasquini
Andrea Pasquini - avatar
3 odpowiedzi
+ 2
The difference is subtle, but it's not like something that we can ignore. int* a, b, c; // <a> is int pointer, <b> and <c> are regular int (not pointers) int *a, *b, *c; // <a>, <b> and <c> are all int pointers This is no problem obviously if you write each variable on their own lines. But for declaring multiple variables on the same line, the latter is the preference I suppose.
13th Jan 2020, 10:50 AM
Ipang
+ 1
Thanks a lot for this detail
13th Jan 2020, 10:54 AM
Andrea Pasquini
Andrea Pasquini - avatar
0
Both same. There is no difference between them.. Meaning to that variable p is pointer variable of type int. Just alternative representations.
13th Jan 2020, 10:49 AM
Jayakrishna 🇮🇳