Parsing a string with a colon and setting both sides to different variables, C++ -
so trying write simple program takes time input user, , calculates angles between , around hands of analog clock. have run program without parsing , 2 separate inputs wanted parse time @ colon (say, 12:35) , set left side hour variable , right side minutes variable. however, reading examples hard when don't know of lines of code mean. me example , explain each line doing , why use method?
this looking for:
string time = "12:35"; unsigned int hour, minutes; sscanf(time.c_str(), "%2d:%2d", &hour, &minutes); cout << "hour: " << hour << endl; cout << "minutes: " << minutes << endl;
Comments
Post a Comment