Possible Duplicate:
In C, what is the correct syntax for declaring pointers?
Correct C pointer notation
What is the difference between
int* x
and
int *x
(if one exists) ?
If they were each local to different functions (or different files) then they are in different 'scopes' then, YES then can have the same name.
Printing pointers. You can print a pointer value using printf with the %p format specifier. To do so, you should convert the pointer to type void * first using a cast (see below for void * pointers), although on machines that don't have different representations for different pointer types, this may not be necessary.
You need to initialize a pointer by assigning it a valid address. This is normally done via the address-of operator ( & ). The address-of operator ( & ) operates on a variable, and returns the address of the variable. For example, if number is an int variable, &number returns the address of the variable number .
The answer is "no", you cannot change the address of a variable.
They both the same. Only difference is that you cant declare many variables in such way:
int* x, a, b; //a and b are not pointers
int *x, *a, *b; //all are pointers
I use first notation, for me it shows that variable has pointer type, not pointer itself.
It's the same definition of pointer. both are pointer to an int
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With