Introduction to pointers in c
Pointer is a variable just like other variables of c but only difference is unlike the other variable it stores the memory address of any other variables of c. This variable may be type of int, char, array, structure, function or any other pointers. For examples:
(1)
Pointer p which is storing memory address of a int type variable:
int *p=&i;
(2)
Pointer p which is storing memory address of an array:
int (*p)[20]=&arr;
(3)
char(*p)(void)=&display;
(4)
int a;
float b;
}var;
struct abc *p=&var;
For pictorial explanation of pointer CLICK ME.
How to read complex pointer
Arithmetic operation with pointer
Pointer to function
Pointer to array of function
Pointer to array of string
Pointer to structure
pointer to union
Multi level pointer
Pointer to array of pointer to string
Pointer to three dimentional array
Pointer to two dimensional array
Sorting of array using pointer
Pointer to array of array
Pointer to array of union
Pointer to array of structure
Pointer to array of character
Pointer to array of integer
Complex pointer
Generic pointer
Null pointer
Wild pointer
Dangling pointer
Near pointer
Far pointer
Graphics video memory
Text video memory
Huge pointer
Memory model in C
10 comments:
int (*p)[20]=&arr;
can u explain what this line does
when we point the structure means will pointer occupy 2 bytes or more than that a?
it depends on memory management in system because in 16 bit system pointer points to 16 bit address and takes 2bytes, even if it is for struct or anithing else
what is the benefit of pointer in c programming.....
good knowledge of c pointer
ajeet
Its tough to get Pointers understanding.
i think the line *p= &i;
is incorrect its invalid conversion from int* to int
as per the compiation in Dev C++ 4.9.9.2
int(*p)[20]=&arr;
it is basically create a variable p and let p has the address of arr first element at the same time p has space of 4 bytes to keep the address.
*p=&i;
invalid conversion..please check
int *p=&i
line is absolutely correct.
Checked in minGW as well as DevC++
Post a Comment