read diff in time HH:MM:SS

Hi
I am having some problems with my program. I am trying to get a user to enter two different time and get how much the different it is between them.
The user will input the time in format HH:MM:SS.
I want to save the hours,minutes and second separated. But haven't found a good way to do it. Anyone have any ides?
You could try a stringstream.
1
2
3
4
5
6
7
    string data = "12:34:56";
    istringstream sstr;
    sstr.str(data);
    int hh, mm, ss;
    char delim;
    sstr >> hh >> delim >> mm >> delim >> ss;
    cout << "hour: " << hh << "  min: " << mm << "  sec: " << ss << endl;

Output:
hour: 12  min: 34  sec: 56
Thanks for the help:)
Topic archived. No new replies allowed.