Hi UAll
I want to token out the int from the string "10:20:30", so in these case i have a delimiter as ':'.
Why do i want to do these, because i have to find out the total second in time stamp.
Please Help me
I tried many way but it does not work, may be i am not thinking right.
Here is you go this is what i am trying. I don't know what i am doing wrong
Please look at the code and help me
Thanks
---------------------------------------------------------------------------------
Code:
#include <stdio.h>
#include <string.h>
int strchrall (const char *z,int b)
{
int rValue = 0;
int Signal = 1;
b = (char) b;
do{
if(*z == b)
{
rValue = rValue + 1;
}
if (*z++ == '\0')
{
Signal = 0;
}
} while(Signal);
return rValue;
}
int main ()
{
int all = 0;
int Mintues = 0;
int Second = 0;
int Hours = 0;
// these will tell me how many times
// the delimeter occures in a string
all = strchrall ("0:00:00",':');
// the string can be from the following
// only second 60
// minutes and seconds 01:60
// hours, minutes and seconds 10:20:30
// Having problem figuring out these logic
// All i want out of this is Total Second from time format....
for(int nIndex = 0, nIndex <= all;nIndex++)
{
if(all == 0)
{
Second = atoi(strtok(0:00:00,":"));
}
else if (all == 1)
{
Mintues = atoi(strtok(0:00:00,":"));
char *temp;
while(temp != NULL )
{
}
}
}
return 0;
}