Showing following error
encrypts "world, say hello!" as "xoqmd, rby gflkp!" using "baz" as keyword
\ expected output, but not "ciphertext:xoqmd, szz gflkp!\n"
what should I make change in my command
my code is
#include <stdio.h>
#include <cs50.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
// functions declarations
// check whether input is capital or small
int check(char x, int y);
// checks the argument line
int check1(char arg[]);
// changes the argument into digits as 'a' or 'A' as 0
int change(char argument);
// encrypt the capital letters
int capital(char x, int y);
// encrypt the small letters
int small(char x, int y);
int main(int argc, string argv[])
{
// checking command line
int check2 = check1( argv[1] );
if (argc != 2 || check2)
{
printf("Error in command line\n");
return 1;
}
else
{
// chaninging argv into digit
int k[strlen(argv[1])];
for (int i = 0; i < strlen(argv[1]); i++)
{
k[i] = change(argv[1][i]);
}
// asks user for plaintwext
printf("plaintext:");
string plain = GetString();
// checks size of plaintext
int size = strlen(plain);
// for repeating the code word
int repeat[size];
for (int i = 0; i < size; i++)
{
int mod = i % strlen(argv[1]);
repeat[i] = k[mod];
}
int cipher[size];
// cipher the plaintext
for (int i = 0; i < size; i++)
{
cipher[i] = check (plain[i], repeat[i]);
}
// prints the ciphered text
printf("ciphertext:");
for (int j = 0; j < size; j++)
{
printf("%c", (char) cipher[j]);
}
}
printf("\n");
}
int check1(char arg[])
{
int j = 0;
if (arg != NULL)
{
int k = strlen(arg);
for (int i = 0; i < k; i++)
{
if (isdigit(arg[i]))
{
j = 1;
}
}
}
return j;
}
// check whether input is capital or small
int check(char x, int y)
{
int valid;
if ( ( x >= 'A' ) && ( x <= 'Z' ) )
{
valid = capital ( x, y);
}
else
{
if (( x >= 'a' ) && ( x <= 'z' ))
{
valid = small ( x, y );
}
else
{
valid = x;
}
}
return valid;
}
// changes the argument into digits as 'a' or 'A' as 0
int change(char argument)
{
int code;
if ( ( argument >= 'A' ) && ( argument <= 'Z' ) )
{
code = argument - 65;
}
else
{
code = argument - 97;
}
return code;
}
// encrypt the capital letters
int capital(char x, int y)
{
int valid = x + y;
while ( valid > 90)
{
valid = valid - 26;
}
return valid;
}
// encrypt the small letters
int small(char x, int y)
{
int valid = x + y;
while ( valid > 122)
{
valid = valid - 26;
}
return valid;
}