Quote:
|
Originally Posted by aedude94
...you input two times in hh:mm:ss format and then add those two times together and output that new time in the same format.
|
You will need to study the functions defined in
ctime.h:
http://www.cplusplus.com/reference/clibrary/ctime/
Note that none of these functions convert from a string representation to one of the common time structures. Given that you are a newcomer to C++, I suspect your instructor is wanting you to do
all the conversions yourself. Decomposing a string into hours, minutes, & seconds can be done a number of ways; some of these methods include:
- Use strtok() which is a traditionally a way C programmers would parse strings.
- Use the string::substr() method.
- Use the string::find_first_of() method.
All of these functions are described at sources such as
cplusplus.com. Once you have isolated strings representing numeric values, you can use functions such as
atoi() to convert to numeric values.
As for converting from one unit of time to another
(eg. minutes -> hours, etc.), I tend to think that your instructor is wanting you to perform the appropriate arithmetic within your code.