I am trying to complete the caesar problem, but my program is not working properly. I know I need to add some code at the beginning to ensure the 2nd argument is legitimate, but I'm just wondering why my program is not processing the for loop once I enter plain text:
#include <cs50.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
int main(int argc, string argv[])
{ //making sure argc is equal to 2 else program does not run
if (argc != 2)
printf("Error\n");
//converting second command line argument from string to int
int k = atoi(argv[1]);
//getting plain text from user
string p = get_string("Plain text: ");
for(int i = 0, n = strlen(p); i > n; i++)
{
if(isalpha(p[i]))
{
if (islower(p[i]))
{
printf("%c", p[i] - (((97)+k)%26)+97);
}
else
{
printf("%c", p[i] - (((65)+k)%26)+65);
}
}
else
{
printf("%c", p[i]);
}
}
}
My program is not bringing up any errors when I 'make' it, but when I enter 'Hello' as the plain text the program does not return anything. Could anyone help by telling me why?
Much appreciated, Dan