what is the output of this code after compiling with C compiler #include <time.h
ID: 3803090 • Letter: W
Question
what is the output of this code after compiling with C compiler
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys.stat.h>
#include <sys/types.h>
int main (int argc, char *argv[] )
{
struct stat file_stats;
if (argc !=2)
fprintf ( stderr, “usage: fstat FILE… ”), exit (EXIT_FAILURE);
if ((stat (argv [1], &file_stats)) == -1)
{
perrr(“fstat”);
return 1;
}
printf (“ filename: %s ”, argv[1]);
printf (“ device: %11d ”, file_stat.st_dev);
printf (“ inode: %1d ”, file_stat.st_ino);
printf (“ protection: %0 ”, file_stat.st_mode);
printf (“ number of hard links: %d ”, file_stat.st_nlinks);
printf (“ user ID of owner : %d ” , file_stat.st_uid);
printf (“ group ID of owner : %d ”, file_stat.st_gid);
printf (“ device type ( if inode device) : %11d ”, file_stat.st_rdev);
printf (“ total size , in bytes: %1d ”, file_stat.st_size);
printf (“ blocksize for filesystem I/O : %1d ”, file_stat.st_blksize);
printf (“ time of last access: %1d: %s” , file_stat.st_atime, ctim ( &file_stats.st_atime));
pritf ( “time of last change: %1d: %s”, file_stat.st_mtime, ctime ( &file_stats_mtime));
return 0 ;
}
Explanation / Answer
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys.stat.h>
#include <sys/types.h>
int main (int argc, char *argv[] )
{
struct stat file_stat;
if (argc !=2)
fprintf ( stderr, "usage: fstat FILE… "), exit (EXIT_FAILURE);
if ((stat (argv [1], &file_stat)) == -1)
{
perrr("fstat");
return 1;
}
printf (" filename: %s ", argv[1]);
printf (" device: %11d " file_stat.st_dev);
printf (" inode: %1d " ,file_stat.st_ino);
printf (" protection: %0 ", file_stat.st_mode);
printf (" number of hard links: %d ", file_stat.st_nlinks);
printf (" user ID of owner : %d ", file_stat.st_uid);
printf (" group ID of owner : %d ", file_stat.st_gid);
printf (" device type ( if inode device) : %11d ", file_stat.st_rdev);
printf (" total size , in bytes: %1d ", file_stat.st_size);
printf (" blocksize for filesystem I/O : %1d ", file_stat.st_blksize);
printf (" time of last access: %1d: %s" , file_stat.st_atime, ctim ( &file_stats.st_atime));
printf ( "time of last change: %1d: %s", file_stat.st_mtime, ctime ( &file_stats_mtime));
return 0 ;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.