port c codes to c++