• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 264
  • Last Modified:

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?
0
jmf8883
Asked:
jmf8883
2 Solutions
 
Kent OlsenData Warehouse Architect / DBACommented:
Hi jmf8883,

They are the same.  C/C++ are very friendly with regard to optional spacing.  Use whatever looks right to you.


Good Luck,
Kent
0
 
jkrCommented:
Yes, thed indeed mean the same, you can even omit the spaces completely.
0
 
jmf8883Author Commented:
thanks
0
 
peetmCommented:
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.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now