2021年1月29日星期五

CS50 Caesar multiple errors

I'm working on Caesar of CS50 and I don't know what's wrong with this code. I keep getting 5 errors and 1 warning (scroll down). I have done my best so far to fix it but I honestly don't know what to do.

#include <stdio.h>  #include <cs50.h>  #include <string.h>  #include <ctype.h>  #include <stdlib.h>  bool check_valid_key(string s);    int main(int argc, string argv[])  {      if (argc != 2 || !check_valid_key(argv[1]))      {          printf("Usage: ./caesar key\n");          return 1;      }      int key = atoi(argv[1]);        string plaintext = get_string("plaintext: ");        printf("ciphertext: ");      for (int i = 0, len = strlen(plaintext); i < len; i++)      {          char c = plaintext[i];          if (isalpha(c))          {              char m = 'A';              if (islower(c))                  m = 'a';              printf("%c", (c - m + key) % 26 + m);          }          else              printf("%c", c);      }      printf("\n");   }     bool check_valid_key(string s);   {       for (int i = 0, len = strlen(s); i < len; i++)          if (!isdigit(s[i]))              return false;      return true;   }  

enter image description here

https://stackoverflow.com/questions/65963505/cs50-caesar-multiple-errors January 30, 2021 at 08:38AM

没有评论:

发表评论