Simple switch case with date not working
I am having a problem type casting my strftime buffer to work with my switchcase statement. Switchcase only uses string/char/int variable, However stftime is something along the lines of a date type variable, so it's not working with my switch case statement.
In short, I need to convert my strftime buffer variable into a char variable to print the correct day of week.
Code:
#include <stdio.h>
#include <time.h> /* time_t, struct tm, time, gmtime */
int main ()
{
// Get a tm structure
time_t now = time(NULL);
struct tm *tick_time = localtime(&now);
// Create a long-lived Time buffer
static char buffer[0];
strftime(buffer, sizeof("0"), "%u", tick_time);
char p = atoi(buffer);
switch(p)
{
case '1' :
printf ("mo");
break;
case '2' :
printf("tu");
break;
case '3' :
printf("wed");
break;
case '4' :
printf("th");
break;
case '5' :
printf("fr");
break;
case '6' :
printf("sa");
break;
default :
printf("su \n");
}
printf(buffer);
return 0;
}
Help would be greatly appreciated.