【发布时间】:2020-02-03 05:38:45
【问题描述】:
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
if (isdigit(*argv[1]))
{
int x = atoi(argv[1]);
printf("%d\n", x);
}
return 0;
}
我不明白为什么在使用isdigit() 时需要星号以及为什么在使用atoi() 时不需要星号
【问题讨论】:
-
仅供参考,
isdigit(*argv[1])应该是isdigit((unsigned char) *argv[1]),因为 C 标准不保证isdigit对char有效,除了基本字符集。
标签: c dereference