The answers to these questions are the same for C and C++.
For getting the user ID of the current process:
For getting the command line of process XXX, where XXX is some process number, look at /proc/XXX/cmdline. Although not a real file, it acts like one, in that you can read it. It contains all parts of the command line. Each part is followed by a single NUL character.
Hope this helps.