Understanding Pointers (for beginners)

Variable definition:


The symbol table is used to get the actually address of variable name.

Pointer Variable is:

pointer variable

The pointer type need two elements, name and type. The name of point represents the address of variable.By the name, we can find the other address (rvalue).

The type of point represents the length that the point move each time. The type is different, the step that point adding 1 indicate is different.

Pointer with Array:

pointer array

The Array essentially is the area of memory. It has continuous part of memory and every part’s type is same.

The pointer indicates the start position of array. When adding 1, the pointer add the length of type.

The address of the array is constant, we don’t change the address of array.

Pointer with string:

pointer string

//The compiler would count the characters, 
// leave room for the nul character and store the total of the four characters in memory
//Strong in the static memory block are taken up
// my_name is a constant
char my_name[] = "Ted";

//Pointer address is stored in stack
// my_name is a variable
char *my_name = "Ted";

void funcA(char *ptr){
    // a is in the stack, copy data from the data space
    // data in the stack
    // By making a[] static, forcing the complier to place
    // data to the stack
    char a[] = "ABCDE";

void funcB(char* ptr){
    //pointer to the address of the data in the data space
    // data still in the data space
    char *cp = "ABCDE";

Pointer with structure:

pointer with structure

The structure also is continuous memory, but it doesn’t represent the unique type. It encompass the mix of the many basic types.

The pointer only indicates the start of the structure, you can find the member by the operation (->) or you can move the pointer with the length of the type that member is.

Pointer with the Arrays of Arrays: