Even after years of C, pointers still confuse me.
Are these two the same:
int *num;
someFunc(num)
and
int num;
someFunc(&num);
Declaring a variable with * makes it a pointer, & turns a variable (momentarily) into a pointer?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No they are not the same. In the first case you have a pointer which is pointing to some random memory location (as you have not initialized it). In the second case, the pointer obtained in
someFuncwill be pointing to a valid location (the address of variablenum).