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

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -