Exercise 1
C Programs
This exercise is intended to check that you have a functioning environment with the C programming language on your workstation, for example, an editor like ee or vim and a compiler like gcc (GNU Compiler Collection) or clang (part of the LLVM project).
The shell command date outputs the current date and time:
date
Thu Jan 1 00:00:00 UTC 1970Write two C programs that also output the current time in a similar way using:
-
time(), followed byctime() -
time(), followed bylocaltime()andstrftime()
If you need information about the C functions, the following man commands will help you:
man 3 time
man 3 strftimetime() + ctime()
time() + localtime() + strftime()