开发者

C programming check digit

开发者 https://www.devze.com 2023-01-22 15:22 出处:网络
bool print_date(Date *d, char **argv) { if (isdigit(*argv+1)) { return printf(\"is d\"); } else { return printf(\"is not d\");
bool print_date(Date *d, char **argv) {

        if (isdigit(*argv+1)) {
                return printf("is d");
        } else {
                return printf("is not d");
        }

}

The above function don't work. *argv+1 is the user input, is it a string or what types when passing in? anyone can help?

 int main(int argc, char *argv[])
 {

  Date d;

  get_date(&d, arg开发者_开发百科v);


 }


*argv+1 computes the address to the first character of the 0-th argument (that is the executable name) and adds 1 to shift to second char of it.. I don't think this is what you want to do.

You could try by using argv[1], this will mean the first argument after the executable name, as a char *.


I am guessing that what you really want is *(argv + 1). The way you have it written is that it will dereference the first character of the program, add one and then test if it is a digit.

0

精彩评论

暂无评论...
验证码 换一张
取 消