小编Mao*_*aii的帖子

“if (isupper(argument) == true)”和“if (isupper(argument))”有什么区别?注意:参数是我程序中的任何字符

我正在做CS50的凯撒问题集,当我尝试移动大写字母时,if (isupper(argument) == true)用来检查我想要移动的字符是否为大写,它没有用,它认为大写字母实际上不是大写。当我将其切换到 时if (isupper(argument)),程序正确地移动了大写字母。这两种格式有什么区别吗?这是我使用的代码(我指的是 for 循环中的代码):

#include <stdio.h>
#include <cs50.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>

int main(int argc, char *argv[])
{
    //Check wether there is only 1 command line argument
    if (argc == 2)
    {
        //Check if there is any character that's not a digit
        for (int i = 0; i < strlen(argv[1]); i++)
        {
            if (isdigit(argv[1][i]) == false)
            {
                printf("Usage: ./caesar key\n");
                return 1;
            }
        }
    }
    else
    {
        printf("Usage: ./caesar key\n"); …
Run Code Online (Sandbox Code Playgroud)

c cs50

1
推荐指数
2
解决办法
87
查看次数

标签 统计

c ×1

cs50 ×1