You are viewing a single comment's thread. Return to all comments →
Your solution is fine. But the sample input is "07:05:45PM" i.e including ":" (colons). Can you please tell me why did you omit this while taking input? Or is it not necessary?
Ultimately, it's up to you how you want to solve it. I found "extracting integers and later printing them with colons" easier than working with strings. Hence, I used scanf+printf for extracting & printing the result.
okay. Also, in scanf, colons doesn't affect input with colons, is it any property of scanf? Like Input is 07:45:54PM and in scanf also, colons are there.
scanf() allows us to read input in some specified format as described by the function parameters.
Colons did affect the input. We used %d:%d:%d to read input of the format hh:mm:ss. If the input had been space separated instead of colons as in hh mm ss, we would have used %d %d %d or simply %d%d%d instead.
%d %d %d