Question: Write this in C/shell programming not C++. Thanks. Task 2: Printing the time that the file path was created (50 points) The stat system call

Write this in C/shell programming not C++. Thanks.Write this in C/shell programming not C++. Thanks. Task 2: Printing the

Task 2: Printing the time that the file path was created (50 points) The stat system call can access a file by name and retrieve file status information. It is given by: int stat (const char *pathname, struct stat buf); This system call returns a stal structure (both the function and struct are called stat), which contains the following fields: struct stat dev_tst_dev; /* ID of device containing file * ino_tst_ino; /* inode number mode_tst_mode; protection nlink tst nlink; /* number of hard links uid tst uid; /* user ID of owner gid tst gid; /* group ID of owner * dev_tst_rdev; /* device ID (if special file) * ofrt st size; /* total size, in bytes blksize tst blksize; /blocksize for file system 10! blkent tst blocks; /* number of 512B blocks allocated time t statime; /* time of last access * time_tst_mtime; /* time of last modification */ timet stctime; time of last status change */ On success, zero is returned. On error, -1 is returned, and errno is set appropriately. The following program displays the time that the file path was last accessed. Type in and complete the following program on the computer. Save it as printaccess.c. Compile the program, then execute it by giving it a path name as an argument. printaccess.c: #include #include #include int main(int arge, char *argv[]) // define an instance of struct stat (don't use a pointer) // Use the stat function store the status of the file in your stat struct 1/ stat takes a pointer, so pass your struct by reference with & if - .1) // use perror to print error message then exit program Il print the last access time for the file using defined instance of Il struct stat. ctime requires a pointer, hence the & below. printf("%s last accessed at %s", argv[1], ctime(&_ _st_atime))

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!