#include // for cout #include // for lstat #include // for lstat #include // for lstat using namespace std; int main() { // lstat has to put the information somewhere, namely, // in an object of type “struct stat”. Here it is. struct stat statbuf; // Get the information about the file /etc/motd, and put it in statbuf. // Return 0 upon success, -1 upon failure. int result = lstat("/etc/motd", &statbuf); if (result != 0) { cerr << "lstat /etc/motd failed\n"; return 1; } // Display some fields from the statbuf object. // They’re not necessarily in the format that you like. cout << "owner: " << statbuf.st_uid << '\n'; cout << "size: " << statbuf.st_size << '\n'; cout << "modified: " << statbuf.st_mtime << '\n'; // This program succeeded--indicate that with a zero. return 0; }