i have the following function
Code:
void fixdate(char *pt, int* d, int* m, int* y, int* h, int* min, int* pa)
{
char month[3];
sscanf(pt, "%*s %d %s %d %d %d", d, month, y, h, min);
if(*h>12)
{
*h = *h - 12;
*pa = 2;
}
else
{
*pa = 1;
}
if(strcmp(month,"Jan") == 0)
{
*m = 1;
}
if(strcmp(month,"Feb") == 0)
{
*m = 2;
}
if(strcmp(month,"Mar") == 0)
{
*m = 3;
}
if(strcmp(month,"Apr") == 0)
{
*m = 4;
}
if(strcmp(month,"May") == 0)
{
*m = 5;
}
if(strcmp(month,"Jun") == 0)
{
*m = 6;
}
if(strcmp(month,"Jul") == 0)
{
*m = 7;
}
if(strcmp(month,"Aug") == 0)
{
*m = 8;
}
if(strcmp(month,"Sep") == 0)
{
*m = 9;
}
if(strcmp(month,"Oct") == 0)
{
*m = 10;
}
if(strcmp(month,"Nov") == 0)
{
*m = 11;
}
if(strcmp(month,"Dec") == 0)
{
*m = 12;
}
}
i try to scan string with the following format sample
Date: 25 Sep 2002 14:52:31
when i check the values, the minute int equals 0. How can i properly scan the string taking in account the format of the string?
i'm using sscanf(pt, "%*s %d %s %d %d %d", d, month, y, h, min);
what should i change?