C
collinm
hi
i would like to take a string and parse it to put her value in a tm
my struct:
typedef struct production_s
....
struct tm tmbStartRun;
struct tm tmbEndRun;
char time_rtu_debut[15];
char htime_rtu_debut[15];
....
} production_t;
printf("prod->htime_rtu_fin%s\n", prod->htime_rtu_fin); // 16:08:55
parseDate(&prod->tmbEndRun, date_rtu);
parseTime(&prod->tmbEndRun, prod->htime_rtu_fin);
printf("prod->htime_rtu_fin%s\n", prod->htime_rtu_fin); //16
void parseDate(struct tm *tm, char tmpdate[])
{
#define DELIM_DATE "/"
char *sep = strtok(tmpdate, DELIM_DATE);
int i=0;
while (sep != NULL)
{
i++;
if(sep!=NULL)
{
if(i==1)
tm->tm_year = 100+atoi(sep);
if(i==2)
tm->tm_mon= atoi(sep);
if(i==3)
tm->tm_mday= atoi(sep);
}
sep = strtok(NULL, DELIM_DATE);
}
}
void parseTime(struct tm *tm, char tmptime[])
{
#define DELIM_TIME ":"
char *sep = strtok(tmptime, DELIM_TIME);
int i=0;
while (sep != NULL)
{
i++;
if(sep!=NULL)
{
if(i==1)
tm->tm_hour = atoi(sep);
if(i==2)
tm->tm_min= atoi(sep);
if(i==3)
tm->tm_sec= atoi(sep);
}
sep = strtok(NULL, DELIM_TIME);
}
}
why prod->htime_rtu_fin display me 16? what happen with her value
16:08:55
thanks
i would like to take a string and parse it to put her value in a tm
my struct:
typedef struct production_s
....
struct tm tmbStartRun;
struct tm tmbEndRun;
char time_rtu_debut[15];
char htime_rtu_debut[15];
....
} production_t;
printf("prod->htime_rtu_fin%s\n", prod->htime_rtu_fin); // 16:08:55
parseDate(&prod->tmbEndRun, date_rtu);
parseTime(&prod->tmbEndRun, prod->htime_rtu_fin);
printf("prod->htime_rtu_fin%s\n", prod->htime_rtu_fin); //16
void parseDate(struct tm *tm, char tmpdate[])
{
#define DELIM_DATE "/"
char *sep = strtok(tmpdate, DELIM_DATE);
int i=0;
while (sep != NULL)
{
i++;
if(sep!=NULL)
{
if(i==1)
tm->tm_year = 100+atoi(sep);
if(i==2)
tm->tm_mon= atoi(sep);
if(i==3)
tm->tm_mday= atoi(sep);
}
sep = strtok(NULL, DELIM_DATE);
}
}
void parseTime(struct tm *tm, char tmptime[])
{
#define DELIM_TIME ":"
char *sep = strtok(tmptime, DELIM_TIME);
int i=0;
while (sep != NULL)
{
i++;
if(sep!=NULL)
{
if(i==1)
tm->tm_hour = atoi(sep);
if(i==2)
tm->tm_min= atoi(sep);
if(i==3)
tm->tm_sec= atoi(sep);
}
sep = strtok(NULL, DELIM_TIME);
}
}
why prod->htime_rtu_fin display me 16? what happen with her value
16:08:55
thanks