Computer Programming Midterm Reviewer
Computer Programming Midterm Reviewer
Computer Programming Midterm Reviewer
int main ()
{
int var = 20; /* actual variable declaration */
int *ip; /* pointer variable declaration */
ip = &var; /* store address of var in pointer variable*/
return 0;
}
Sample Run:
Address of var variable: bffd8b3c
Address stored in ip variable: bffd8b3c
Value of *ip variable: 20
POINTER IN DETAILS
Pointer Arithmetic
- There are four arithmetic operators that can be used
in pointers: ++, - , + , -
Array of Pointers
- You can define arrays to hold a number of pointers
Pointer to Pointer
- C allows you to have pointer on a pointer and so on.
Passing Pointers to Functions in C
- Passing an argument by reference or by address
enable the passed argument to be changed in the
calling function by the called function
Return Pointer from Functions in C
- C allows a function to return a pointer to the local
variable, static variable, and dynamically allocated
memory as well.