I keep finding this message when i run my Caesar Cipher code.
It complies, but then displays this message. I can't seem to find an answer to this problem anywhere as all the other posts on this topic don't seem to have any resemblence to my problem
My code is:
Code:
/* The program encrypts a string using the caesar cypher*/
#include<cs50.h>
#include<stdio.h>
#include<ctype.h>
#include<stdlib.h>
#include<string.h>
int main(int argc, char *argv[])
{
// check if the argument entered is a number
if (!isdigit(*argv[1]) || argc !=2)
{
printf("Please enter one number as the argument to use to encrypt\n");
return 1;
}
// convert the argument to an int
int k = atoi(argv[1]);
// get the user's plaintext to encrypt
printf("\nplaintext: ");
char *plain = GetString();
// encrypt
printf("\ncyphertext: ");
for (int i = 0, n = strlen(plain); i < n; i++)
{
// if the letters are lowercase
if(plain[i] > 64 && plain[i] < 91)
{
int ascii = plain[i];
int p = (ascii - 65);
int c = (p + k) % 26;
int cypher_p = (c + 65);
printf("%c", cypher_p);
}
// if the letters are uppercase
// this is where the error is
else if(plain[i] > 96 && plain[i] < 123)
{
int ascii = plain[i];
int p = (ascii - 97);
int c = (p + k) % 26;
int cypher_p = (c + 97);
printf("%c", cypher_p);
}
// if the element in plain is a space print a space
else if(strcmp(&plain[i], " ") == 0)
{
printf(" ");
}
}
printf("\n");
}