jmf8883
asked on
C++ Pointers
This is a fairly simple question but I just want to make sure. Do char* c char * c and char *c all mean the same thing or are they different?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Yes, they all mean the same syntactically - however, from a human semantics point of view, they often don't!
For example, one often sees something like this:
1. char *p;
2. *p = ...
Here, in '1', *p declares a pointer to a character.
in '2' *p IS a char.
So, if I said to you what's *p what would you say?
Now consider:
1. char * p;
2. *p = ...
In '1' we now have '*<>p' which at least gives a hint that, as in '2', *p is different, i.e., we use white-space to *help* ourselves and others to note that the two are not the same - in the first notation, *p/*p look the same, but are different, in'2' * p/*p might show those who are less savy that something's not quite the same.
For example, one often sees something like this:
1. char *p;
2. *p = ...
Here, in '1', *p declares a pointer to a character.
in '2' *p IS a char.
So, if I said to you what's *p what would you say?
Now consider:
1. char * p;
2. *p = ...
In '1' we now have '*<>p' which at least gives a hint that, as in '2', *p is different, i.e., we use white-space to *help* ourselves and others to note that the two are not the same - in the first notation, *p/*p look the same, but are different, in'2' * p/*p might show those who are less savy that something's not quite the same.
ASKER