I know char *x
means a pointer to char, but I\'m confused about what (char*) x
means.
It's a cast. You are instructing the compiler to treat x
as if it were a char *
, regardless of its real type. Casts should only be used if you really know what you are doing.
For some built-in types, the compiler may perform a meaningful conversion, e.g. converting a double
to an int
by rounding, but for other types you may not get what you expect.