Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C 以hh:mm:ss形式给出的时间为单位,以整数形式表示时分秒_C - Fatal编程技术网

C 以hh:mm:ss形式给出的时间为单位,以整数形式表示时分秒

C 以hh:mm:ss形式给出的时间为单位,以整数形式表示时分秒,c,C,我试过使用: scanf("%d %d %d", &hour, &min, &sec); printf("%d %d %d", hour, min, sec); 但它不起作用,我想我必须绕过“:”但我不确定如何做到这一点 干杯请尝试: if (scanf("%d:%d:%d", &hour, &min, &sec) != 3) …error handling… 请尝试: if (scanf("%d:%d:%d", &hour,

我试过使用:

scanf("%d %d %d", &hour, &min, &sec);
printf("%d %d %d", hour, min, sec);
但它不起作用,我想我必须绕过“:”但我不确定如何做到这一点

干杯

请尝试:

if (scanf("%d:%d:%d", &hour, &min, &sec) != 3)
    …error handling…
请尝试:

if (scanf("%d:%d:%d", &hour, &min, &sec) != 3)
    …error handling…

还要看一看。还要看一看。调用任何
scanf()
函数族时,始终检查返回值(而不是参数值)以确保操作成功。调用任何
scanf()
函数族时,始终检查返回值(而不是参数值)确保手术成功。