But if i have g++ compailer it is compatible.
No they are not. Read the link I posted earlier about the differences between the two languages. You can not always compile a C program with a c++ compiler without making some changes. One simple example: char *ptr = malloc(255);
. That will compile with C but not C++.