+ 1

How int* x is different from int *x

7th Aug 2019, 12:38 AM
JAMEEMA B
JAMEEMA B - avatar
4 Respuestas
+ 3
They are the same thing
7th Aug 2019, 1:07 AM
Paolo Luigi Rinaldi
Paolo Luigi Rinaldi - avatar
+ 3
Like Paolo Luigi Rinaldi said. C/C++ gives you a chance to do the same thing in different ways.
7th Aug 2019, 2:10 AM
Manual
Manual - avatar
+ 1
EDIT: After confirming I actually found that int* a,b; and int *a,b; are both exactly the same. In reality, the operator * binds to the identifier and not the type... And hence this misunderstanding arises. So in order to prevent this misunderstanding from occuring in the future, I would strongly suggest that you use int *a,b; As the other method can be easily misunderstood... Thanks Paolo Luigi Rinaldi for pointing out the error in my initial answer...
7th Aug 2019, 12:50 PM
Grizzly Gunner
Grizzly Gunner - avatar
+ 1
Are you sure Namit Shah? I've just tried the Case 2 and the compiler tells me that b and c are int. I may have misunderstood though...
7th Aug 2019, 1:01 PM
Paolo Luigi Rinaldi
Paolo Luigi Rinaldi - avatar