I'm still trying to figure out why my code isn't working, if anyone can offer any insight, it would be very appreciated!
#include <cs50.h>
#include <ctype.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, string arvg[])
{
//this make prints an error is cla is not 2
if (argc != 2)
{
printf("No good, it doesn't equal 2 \n");
return 1;
}
//this converts integers to characters
int key = atoi(arvg[1]);
//this makes sure it's a non-negative integer
if (key < 0)
{
printf("No good, it's zero\n");
return 1;
}
else
{
string plaintext = get_string("plaintext: ");
printf("ciphertext: ");
for (int i = 0, n = strlen(plaintext); n < i; i++)
{
//check lowercase
if (islower(plaintext[i]))
{
printf("%c", (((plaintext[i] - 97 + key) % 26) + 97));
}
//check uppercase
else if (isupper(plaintext[i]))
{
printf("%c", (((plaintext[i] - 65 + key) % 26) + 65));
}
else
{
printf("%c", plaintext [i]);
}
}
}
printf("\n");
return 0;
}