Tag Archives: C&C++

compiler study 5 – crowbar whole workflow

here is the full-featured markdown version : full version, which has better markdown support such as sequential graph and flow chart. I debugged the crowbar program, just have a rough idea how the crowbar works. test case 1 preparation write … Continue reading

Posted in programming | Tagged , | Leave a comment

compiler study 4 – crowbar debug and code analysis

compiler study 4 – crowbar here is the full-featured markdown version : full version, which has better markdown support such as sequential graph and flow chart. debug on mac, the gdb has been replaced with lldb, here is some debug … Continue reading

Posted in programming | Tagged , | Leave a comment

compiler study 3 – crowbar compile and interpret flow

compiler study 3 – crowbar here is the full-featured markdown version : full version, which has better markdown support such as sequential graph and flow chart. CRB_compile CRB_compile would do several things : 1. lex the source code to token … Continue reading

Posted in programming | Tagged , | Leave a comment

compiler study 2 – crowbar lex and yacc

compiler study 2 – crowbar here is the full-featured markdown version : full version, which has better markdown support such as sequential graph and flow chart. lex string.c – crb_create_identifier, allocate memory for identifier and add the memory to the … Continue reading

Posted in programming | Tagged , | Leave a comment

c pointer and mutiple dimension array

Sometimes I am still a little bit confused by the relationship between a pointer and a multiple dimensional array. Let’s see some sample code: #include <stdio.h> // void printArr( int *arr, int row, int col ){    int i, j;    for( … Continue reading

Posted in programming | Tagged | 1 Comment

a bug for visual studio 2008?

Here is a sample code, runs well in GCC, but not in visual studio 2008. #include <stdio.h>using namespace std;int main( void ){    printf( “%s\n”, “hello” );} but in visual studio 2008, I got   in order to make the namespace … Continue reading

Posted in programming | Tagged | Leave a comment

what’s the usage of header guard?

When you create header file in Code::Block, you would always see something like this : #ifndef LEFTROTATION_H_INCLUDED#define LEFTROTATION_H_INCLUDED .. #endif why these header guard should be there? Suppose you have a header file named a.h,  then in multiple file, let’s … Continue reading

Posted in programming | Tagged | Leave a comment

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