tags:

views:

227

answers:

7

I think that *something and * something are different.

What does the additional white space do?

occurs here -> void * malloc( size_t number_bytes );

+10  A: 

When you use an asterisk to get the value of an address it is called the dereference operator. For example:

int x = *something;

In the example in your question the asterisk has a different meaning because it is part of a type, not part of an expression. It is used to specify that the return type is a pointer (in your specific example, a void pointer).

The extra space does not mean anything and is ignored by the compiler. It is there only to aid readability.

Mark Byers
A: 

The same thing, but with some whitespace added.

Mike Caron
+1  A: 

C ignores extraneous whitespace, so "* " should have the same effect as "*".

If you want more clarification, please post a code example.

Justin Ethier
A: 

Check out this article on Pointers

Those two lines do the exact same thing.

Robert Greiner
A: 

In your void * malloc(...) example, void * is the type. malloc returns a pointer to void, which is just a pointer that needs to be cast to a particular type in order to be useful.

Nathon
+5  A: 
int* foo == int *foo == int * foo == int  *   foo

The whitespace does not make any difference to the compiler.

Justin Ardini
this is what I call a true example
Delirium tremens
Would the downvoter care to explain?
Justin Ardini
I didn't downvote, but given this is a noob question, you may want to avoid the use of `==` in that context as it is not valid syntax and could confuse learners.
bstpierre
A: 

The * operator in a declaration always binds to the declarator; the line

void * malloc (size_t number_bytes);

is parsed as though it had been written

void (*malloc(size_t number_bytes));

It's an accident of C syntax that you can write T *p; or T* p; or even

T             *                     p; 

but all of them are parsed as T (*p); -- the whitespace makes no difference in how the declarations are interpreted.

John Bode