Skip to content

Instantly share code, notes, and snippets.

@i0na-k
Created April 11, 2016 16:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save i0na-k/48daba9bb9808ab8d96f05eb04f8fc09 to your computer and use it in GitHub Desktop.
Save i0na-k/48daba9bb9808ab8d96f05eb04f8fc09 to your computer and use it in GitHub Desktop.
#include <cs50.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
int main(int argc, string argv[])
{
if (argc != 2)
return 1;
int k = atoi(argv[1]);
//we want to add the number of k to our plaintext - to do this we need to change from string to int (atoi)
string t = GetString(); //getting plaintext off user; we then need to convert each char in array to ascii value
int i;
for (i=0; i<strlen(t);i++)
{
if (isupper(t[i]));
{
printf ("%c",t[i]+k);
}
if (islower(t[i]));
{
printf("%c", t[i]+k);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment