CS50, caesar solution

4k Views Asked by At

I try to understand what I am doing for programing caesar.c but still not be clear. At lest I want to add isupper and islower and whatelse?

#include<stdio.h>
#include<cs50.h>
#include<stdlib.h>
#include<string.h>
    #include<ctype.h>

    int main (int argc, string argv[])
    {

    int k;
    k =  atoi(argv[1]);

    if(k <=0)
    {
       printf("You must input a non-negative integer.\n");
       return 1;
    }

    printf("What do you want to cipher?\n");
    string cipherInput = GetString();

    if(isalpha(cipherInput))
    {
    for (int i =0, n = strlen(cipherInput); i < n; i++)
    {
             printf("%c", (cipherInput[i] + k % 26));
    }
    }
    else
    {
       printf("%s\n", cipherInput);
     }

     printf("\n");
}                

I want to have a result after compile this Be sure to drink your Ovaltine!

trying hard to understand even rot 13, but I do not have any result yet.

Please give me any suggestions.

Thank you in advance.

1

There are 1 best solutions below

0
On

amazingly accidentally I got this.

V qvq abg hfr netp gb fbyir guvf ceboyrz. strlen(42)

I did not use agrc at this point, though still interested in if it is possible to make it with agrc[]