A pointer, regardless of 'char*', 'int*' 'struct mystruct *', is the same size. A pointer is a variable that stores the memory address of whatever type it is designed to point at. Thus, a "char pointer" is designed to point-at a character. Since it is a pointer to a memory location, it stores the value of that memory location (it's address).
Code:
#include <stdio.h>
int main ( void ) {
printf("char* = %d bytes", sizeof ( char* ) );
printf("int* = %d bytes", sizeof( int* ) );
printf("float* = %d bytes", sizeof( float* ) );
return 0;
}
See? This is different than when you're comparing the 'sizeof' the actual variable.
To use a pointer, you declare one:
char *c; //character pointer, currently points to random memory address
Give it a value. Always do this first. You _have to_ initialize a pointer before using it, or bad things happen:
c = NULL;
You can generally do this in one shot:
char *c = NULL;
Now, if we have this:
char *c = NULL;
char array[10] = "Hello Bob";
We can do something like:
c = array;
Which sets c to store the value of the memory address that the array holds. (Maybe not the best explanation, but basicly, we're "pointing at" our array now.)
Now you can do something like:
puts( c );
Which should print "Hello Bob". (Less quotes.)
Quzah.