#include#include #include #include using namespace std; int main(){ struct passwd *pw; uid_t uid; uid = geteuid(); pw = getpwuid(uid); cout << "Current user: " << pw->pw_name << endl; return 0; }
#includeIn this example, the file permissions for a file are set using the `chmod()` function. This function is part of the `#include #include using namespace std; int main(){ const char* filename = "/path/to/file"; int result = chmod(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); if (result != 0){ cout << "Error setting file permissions." << endl; return 1; } cout << "File permissions set successfully." << endl; return 0; }