Last active
November 16, 2015 06:47
-
-
Save 6uclz1/b5c476ccbc5b4de90d16 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
void encrypt(char*, int); | |
int main() | |
{ | |
int key; | |
char message[20]; | |
printf("? "); | |
scanf("%s", message); | |
printf("key? "); | |
scanf("%d", &key); | |
printf("%s\n", message); | |
encrypt(message, key); | |
printf("%s\n", message); | |
} | |
void encrypt(char *s, int key) | |
{ | |
int i; | |
for(i = 0; *s != '\0'; i++) { | |
*s = *s + (i % key + 1); | |
s++; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment