I'm not quire sure what it is you're asking for, but the easiest way it to use the Raspbian OS which comes with g++ installed.
If you choose the desktop (not Lite version) you will be able to easily edit and compile C/C++ code on you Raspberry.
It is of course also possible with the console only Lite version, but it is easier to have a window for compiling along with your editor.
The most basic syntax of g++ is:
For C code you'll need the gcc compiler:
Sorry - I can't remember which compilers are included on the Raspbian OS images. But cc is installed by default, as jahboater writes above.
There are cross compiler options that allow you to do everything on e.g. Windows and then transfer the executable to the Raspberry Pi. But I haven't used them. I think JetBrains can do that with their IDE CLion.