My best guess is that it isnt your C++ code, because you dont understand it. But I will give you some hints.
As my pre-writers wrote you need to replace the C++ with C function. So visit some
Learn C tutorial to learn the language and especially read carefully all details about the printf(), scanf(), malloc() and free() functions.
With this knowledge you can kickstart your coding task.