Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.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/8/http/4.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和x2B的验证+;_C++ - Fatal编程技术网

C++ 输入程序C和x2B的验证+;

C++ 输入程序C和x2B的验证+;,c++,C++,我需要一些关于我目前正在做的作业的提示。我需要创建一个程序,将时间规格(n1y n2n n3d n4h n5m n6s——请注意,不同输入之间的空白量可能不同)转换为秒。我需要创建的函数之一是验证时间规范输入的函数(作为常量字符*)。函数头如下所示: // is_legal_time_spec: // Checks if ctime_spec is a valid time spec // In: // ctime_spec != NULL // Out: // r

我需要一些关于我目前正在做的作业的提示。我需要创建一个程序,将时间规格(n1y n2n n3d n4h n5m n6s——请注意,不同输入之间的空白量可能不同)转换为秒。我需要创建的函数之一是验证时间规范输入的函数(作为常量字符*)。函数头如下所示:

// is_legal_time_spec:
//      Checks if ctime_spec is a valid time spec
// In:
//      ctime_spec != NULL
// Out:
//      return -- true if the ctime_spec is a valid time spec
//                false if otherwise
bool is_legal_time_spec( const char *ctime_spec ) {
    return false;
}
我有一些关于如何使用strpbrk(3)函数的想法,但我想知道是否还有另一个更简单的函数可以用来检查时间规格输入的格式

提前感谢您的帮助。

用于将字符串拆分为单词,然后通过解析或使用sscanf分别验证每个单词。然后,请先做简单的数学运算,将时间规格转换为秒,然后再推荐
strtok()