Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/58.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中解析小时格式?_C_String_Charts_Format - Fatal编程技术网

如何在c中解析小时格式?

如何在c中解析小时格式?,c,string,charts,format,C,String,Charts,Format,我需要将C中格式为“00:00:00”的字符[]解析为000000,最好的方法是什么 我试着用strok,但没用。 谢谢像这样的东西怎么样: char* time = "00:00:00"; unsigned int h, m, s, result; sscanf(time, "%02u:%02u:%02u", &h, &m, &s); result = (h * 10000) + (m *100) + (s); printf("%u", result); 请显示显

我需要将C中格式为“00:00:00”的字符[]解析为000000,最好的方法是什么

我试着用strok,但没用。
谢谢

像这样的东西怎么样:

char* time = "00:00:00";
unsigned int h, m, s, result;

sscanf(time, "%02u:%02u:%02u", &h, &m, &s);
result = (h * 10000) + (m *100) + (s);

printf("%u", result);
请显示显示您尝试过的内容并解释错误。发布代码“尝试使用strok”。然后解释“它不起作用”的含义。最好的方法是使用库函数。如果您对允许使用哪些函数有限制,请将其添加到问题中。