Episode 3
--storage structure. Ampersand operate with Asterisk
--library function
Episode 4
--generic function Generic Functions
Swap (void* pa,void*pb,int size);
-----Ampersand and asterisk
The original types does not matter much, the pointer does.
When a pointer was operated with a intergral, just remember to transit the intergral into the same type length with the POI Nter.
--big endian, Little endian (most Linux)
-----array
int array[10];
Array = &arry[0];
Array+k = &array[k]; K for pointer operation, to expand to array of the same type length
*array = array[0];
* (ARRAY+K) =array[k];
* (array-4) = 8;
ARRAY[-4] = 8;//there is no bond check in C, so it'll put 8 at the corresponding address. This isn't good//code, the result is unsure, it may crush.
-------liabrary function
--strdup ("ADM"); As it shows itself, only valid to string type.
memcpy Function,return An adress pointed at the heap which store "ADM" (with string end sign).
--strcpy (Paim, "4021");
"4021" is copied to the memory started at address Paim.
--memcpy (void*to,void*from,int size)
Copy designated size to the memory.
------Swap (void* pa,void*pb,int size);
Swap (void* pa,void*pb,int size) { char temp[size]; memcpy (temp,pa,size); memcpy (pa,pb,size); memcpy (pb,temp,size);}
Programming Paradigm Episode3 and 4