In C, why is the asterisk before the variable name, rather than after the type?
In the following declaration:
char* string1, string2;
string1 is a character pointer, but
string2 is a single character only. For this reason, the declaration is usually formatted like:
char *string1, string2;
which makes it slightly clearer that the
* applies to
string1 but not
string2. Good practice is to avoid declaring multiple variables in one declaration, especially if some of them are pointers.