I want to test if current user is a super user. I think the root is a super user. But is it true that, only root is the super user?
Here is a simple algorithm:
I am pretty much sure this is not the way. Can anyone tell me how can I say current user is super user or not.Code:#include <iostream> #include <string> #include <cstdlib> using namespace std; int main() { string name = getenv("USER"); if(name == "root") cout << "super user\n"; else cout << "not a super user\n"; return 0; }
Thanks in advance.
Bookmarks