getuid or geteuid, depending on what you really mean. In either case, 0 means root.
if(geteuid() != 0)
{
// Tell user to run app as root, then exit.
}
The point made by R is valid. You should consider trial and error, or another approach that does not explicitly require root.