Lab 1: Calendar

San Skulrattanakulchai

September 22, 2016

Topics

Commandline Arguments & GNU getopt

Getting Current Month & Year

#include <time.h>
    .
    .
    .
/*
   Set 'month' (in the caller) to current month, and
   set 'year' (in the caller) to current year.
 */
void getMonthYear(int *month, int *year) {
    time_t timenow;
    struct tm *current;
    time(&timenow);
    current = gmtime(&timenow);
    *month = current->tm_mon+1;
    *year = current->tm_year+1900;
}
    .
    .
    .
int month, int year;
getMonthYear(&month, &year);
/* At this point month equals 9 and year equals 2016 */
    .
    .
    .

printf Family of Functions

String Manipulation Functions

Initialization of Arrays

2D Arrays vs Array of Arrays