Search for question
Question

1. Write a complete C program named "cal-time-args.c" that will firstly

check the number of command line arguments. When the total

number of arguments is exactly 2 [YET the input argument may be

invalid], the program will display the local time in number of minutes

since the UTC (i.e. 0:0:0 on January 1, 1970), and also the local time

and date through calling the ctime() function. Then, with the

command line argument as [-S |-s], it will display the Shanghai Time

(UTC + 8). Similarly for the argument [-P | -p], it will display the Paris

Time (UTC +2), and the Fuji Time (UTC+9) for [-F | -f] by making

use of the result returned from the function call gmtime(). Lastly,

the program prints out the time and date of the specified time zone

through invoking the asctime() function for conversion of the time

format. For correctness, your C program will need to handle the

overflow of hours beyond 24 after the conversion from UTC/GMT

time, i.e. hours > 24 after conversion should be wrapped to be

within 24 hours for its correct display (hint: using the modulo [%]

operator). The expected outputs of the "cal-time-args.c" program

are clearly stated as below.