Please enable JavaScript.
Coggle requires JavaScript to display documents.
:ecture 8 - Pointers - Coggle Diagram
:ecture 8 - Pointers
Why
-
-
-
-
-
Ex :struct to represent complex numbers: struct{ float real; float imag;
};
int main(){
struct complex c1,c2;
struct complex cp1, cp2;
cp1=&c1;
(cp1).real= ;
(cp1).imag= ;
}
pointers and function
Characteristic
-
-
pointers are passed by values but using pointers, realize parameters passing by address
How it works
When calling, func code is copied to inde[.area
-
-
-
Example program
Exchange 2 var.
void exchange(int ip1, int ip2){
int temp; temp=ip1;
ip1=ip2;
ip2=temp;
return 0;}
int main(){
int a=5, b=8;
aptr=&a,bptr=&b;
exchange(&a,&b);
exchange(aptr,bptr);
}
-