please, whats the difference between
char* name;
and
char name;
thanx!
please, whats the difference between
char* name;
and
char name;
thanx!
You really should just continue your old thread. That being said, one is a pointer, one is a single character.Originally posted by phptech
please, whats the difference between
char* name;
and
char name;
thanx!
* deontes a pointer. This means that the variable itself doesn't have space allocated to it* but rather, it is used to point to another variable. (Hence the name 'pointer'.)
*The only space allocated there is for the actual pointer itself. You assign pointers the addresses of other variables, not actual data.
If you've got a C book, go read up on pointers. If not, read the FAQ.
Quzah.
Hope is the first step on the road to disappointment.
char* represents a pointer to char, which is a data type that's usually one byte long. This pointer, unless it's allocated or explicitly set, points to memory that's undefined.
char contains only a single variable of the char type.
In holding character strings, you usually define a char array that can hold the desired maximum amount:
Code:char name[200];
Peter O. Programming tips