Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/64.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 使用isdigit()宏分析命令行_C_Macros - Fatal编程技术网

C 使用isdigit()宏分析命令行

C 使用isdigit()宏分析命令行,c,macros,C,Macros,我有以下代码从命令行读取参数。如果字符串的格式为hw:1,0,我想打断它 gboolean parse_one_option (gint opt, const gchar * arg, GError ** err) { switch (opt) { case DEVICE: if (!strncmp(arg, "hw:", 3) && isdigit(arg[3]) && arg[4] == ',' && isdig

我有以下代码从命令行读取参数。如果字符串的格式为hw:1,0,我想打断它

gboolean parse_one_option (gint opt, const gchar * arg, GError ** err)
{
    switch (opt) {
    case DEVICE:
        if (!strncmp(arg, "hw:", 3) && isdigit(arg[3]) && arg[4] == ',' && isdigit(arg[5])) {
            char *device = g_strdup (arg);
            break;
        break;
编译器给了我一个警告:

warning: implicit declaration of function 'isdigit' is invalid in C99 [-Wimplicit-function-declaration]
                    if (!strncmp(arg, "hw:", 3) && isdigit(arg[3]) && arg[4] == ',' && isdigit(arg[5])) {
                                                   ^
还有一个问题:


将g#u strdup与GOptionContext结合使用是正确的

您需要
#include
才能使用此函数/宏。

当遇到
隐式声明警告时
尝试寻找合适的include。我认为
isdigit()
ctype.h
as@nishant中的函数“它们可以实现为宏”,就像它们通常一样。