What is a function that will use stat to get a files st_mode, st_nlinks, st_uid, st_gid, st_size and print?
display_file(file){
stat info = stat(file)
printf(.....)
}
Answer:
The stat() function will obtain the information about the named file and write it to the area pointed to by the buf argument. The path argument points to a path name and also naming a file to read, write, or execute permission of the named file is not particularly required. An implementation that provides additional or alternate file access control mechanisms may, under implementation-defined conditions, cause stat() to fail. In particular, the system may deny the access of existence of the file specified by path.
If the named file is a symbolic link, the stat() function will continue the path name resolution using the contents of the symbolic link, and shall return information pertaining to the resulting file if the file exists.
Thank you!!! Good luck! keep coding :)
Get Answers For Free
Most questions answered within 1 hours.