/******************************************************************* CS167/467 First lab assignment: Edit, compile and run a C program. Before starting you may need to customize your working environment by inserting the following lines into your .cshrc file (note the beginning period) which is a file in your home directory: source /local/config/cshrc.gcc source /local/config/cshrc.emacs If you are a new user with a brand new account, you will not need to do anything. If you are unsure how to do edit your .cshrc, get help! Here is the sequence of steps for the lab assignment: 1. save this message as a file, called message1 2. copy the file to a file called lab1.c by: cp message1 lab1.c 3. edit lab1.c to extract only the program text. 4. edit the comment block to contain your name, save the file 5. compile the program text by: gcc lab1.c 6. run the program by typing a.out to view the output 7. run the program with redirected output by: a.out > lab1.out, where lab1.out is a name of a file 8. use the editor to insert the output file into the program text, at the end of the file. Save this file as lab1.submit 9. print the source code and output by: lpr lab1.submit 10. mail the file to the grader by: mail byao < lab1.submit 11. hand the printed source code and output to me 12. go home happy!! **********************************************************************/ /***************************************************** ** This programs prints time and date on the screen ** ** Roger Hartley, Fall 1999, CS 167/467 ** *****************************************************/ #include #include int main() { time_t clock = time(0); struct tm *clockStruct = localtime(&clock); const int length = 10; char dateString[length], timeString[length]; strftime(dateString, length, "%D", clockStruct); strftime(timeString, length, "%R %p", clockStruct); printf("I finished this at %s on %s\n", timeString, dateString); }