usign c style functions to solve