lstat in unix
I am trying to get the size of a file in bytes using Lstat() in unix. I am getting this error when i try to print out the value "stat.st_size" which should be where the size in bytes is stored right?
The name of the file is take in as a command line argument.
workdamnit.cpp:67: error: request for member `st_size' in `stat', which is
of non-class type `int ()(const char*, stat*)'
Is this more of that crazy pointer stuff? Am I required to use them here?
status = lstat(argv, &buffer);
cout<<"the size is"<< stat.st_size<<endl;
1. The thing you read the file status into is called buffer, not stat
So perhaps buffer.st_size ?
2. There is also a function called stat, which is the symbol you're really trying to use at the moment, and the cause of the function-like error message.
I got it to work. Thank you.