简单密码程序不工作 (CS50)

Simple Cypher Program Not Working (CS50)

在 CS50 的第 2 周,我碰壁了。我的代码应该提示用户输入纯文本,然后在下一行打印一个简单的密码。问题是,我的代码一直在为用户打印准确的输入,而不是乱码。我的代码如下。

注意:我的代码中的错误可能出现在 for 循环中,在各自的 printf 函数中。

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

int main (int argc, string argv[]){
    if (argc != 2){
        printf("You must enter two arguments, the second being a single digit integer!\n");
        return 1;
    }

    int key = atoi(argv[1]);

    printf("What do you want to encrpyt?");
    string s = get_string();


    for(int i=0; i < strlen(s); i++){

       if (isupper(s[i])==true){
       printf("%c",((s[i] + key)));
       }

       if (islower(s[i])==true){
       printf("%c",s[i] + key);
       }

       else {
           printf("%c",s[i]);
       }

    }


}

已修复。 if 语句语法错误,因此程序跳过密文。我需要从 if 语句中删除“==true”。