0

I have tried using:

scanf("%d %d %d", &hour, &min, &sec);
printf("%d %d %d", hour, min, sec);

but it does not work, I think I have to bypass the ":" but am unsure how to do this.

Cheers

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
Jonty
  • 1
  • 1
  • when calling any of the `scanf()` family of functions, always check the returned value (not the parameter values) to assure the operation was successful. – user3629249 Sep 09 '18 at 02:05

1 Answers1

3

Please try:

if (scanf("%d:%d:%d", &hour, &min, &sec) != 3)
    …error handling…
Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
  • Also take a look at [this](https://stackoverflow.com/questions/11213326/how-to-convert-a-string-variable-containing-time-to-time-t-type-in-c). – Chris Aby Antony Sep 07 '18 at 04:14