Using Stat Function to Read Stats of the file

#include 
<iostream>
using namespace std;
int main()
{

struct stat FileInfo;
char filename[20] = "clock.cpp";
//Attempt to get the attribute of the file
int Stat = stat(filename  , &FileInfo );
if (Stat == 0){
    cout << "Success\n";
    cout << "File Info: \n";
    cout << "Size in Bytes : " << FileInfo.st_size << endl;
    cout << "File's Owner Identification Number : " << FileInfo.st_uid << endl;
    }
else{
    cout << "Fail";
    }

return 0;
}

0 notes