Does Int* p and int *p 2 different things? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Does Int* p and int *p 2 different things?

12th Feb 2017, 5:04 PM
Krishan Nandan Goswami
Krishan Nandan Goswami - avatar
3 Answers
+ 11
They're mostly similar until you initialize a bunch of variables at once. Attaching * to the type causes every variable you make in the statement to be a pointer. Ex: int* ptr1, ptr2, ptr3; Placing the * on the variable name makes that one a pointer, but not anything else. Ex: int num1, *intPtr, num2;
12th Feb 2017, 6:17 PM
Tamra
Tamra - avatar
0
thanks
12th Feb 2017, 5:20 PM
Krishan Nandan Goswami
Krishan Nandan Goswami - avatar
- 1
no
12th Feb 2017, 6:33 PM
Mahmoud El Sherbeny
Mahmoud El Sherbeny - avatar