Monthly Archives: April 2012

an segment fault issue

I always will meet some ‘segment fault’ or ‘memory is not accessible’ error when I uses pointers. some memory issue is impercitable. I have a  C function like this : void swap5(char** p, char** t) { char temp = **t; … Continue reading

Posted in programming | Tagged | Leave a comment

c constant pointer

I met a c constant pointer and it take me sometime to figure it out.  Here is the code: char *leftRotation2(char *arr, int N, int K) { while(K–) { int j = arr[N-1]; for(int i=N-1;i>0;i–) { arr[i] = arr[i-1]; } … Continue reading

Posted in programming | Tagged | Leave a comment

c double pointer usage

When I read some C code about tree, C double pointer attract my attention. void insert(node ** tree1, node * item) { 12         if(!(*tree)) { 13                 *tree = item; 14                 return; 15         } 16         if(item->val<(*tree)->val) 17                 insert(&(*tree)->left, item); 18         else … Continue reading

Posted in programming | Tagged | Leave a comment