I am writing an application that requires root user privileges to execute. If executed by a non root user, it exits and terminates with a perror message such as:
#include // getuid
#include // printf
int main()
{
if (getuid()) printf("%s", "You are not root!\n");
else printf("%s", "OK, you are root.\n");
return 0;
}