Simple question is: why do you write
char *foo;
and not
char* foo;
Let me explain: for me (coming from Java) a declaration is something like
<variable-type> <variable-name>;
In the above case I declare a variable named foo of type char* (as it is a pointer pointing to char). But wherever I read c/c++/c#-Code it looks like a variable named *foo of type char. The compiler does not care about whitespaces but I as a developer do.
tl;dr What I ask for is a good explanation for writing char *foo instead of char* foo (what, as explained, seems more convenient for me).
Think of the following declaration:
This declares a pointer to char called
pand a character variable calledc. This shows that it isn’t exactly correct to think of variable declaration as having the simple and clear format you described.