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?
3 Respostas
+ 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.
+ 1
Thanks a lot for this detail
0
Both same. There is no difference between them.. Meaning to that variable p is pointer variable of type int.
Just alternative representations.