Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- int main (void)
- {
- char * test="This is a secret message"; // test input
- const int SHIFT=9; // the shift
- char * coded = malloc(strlen(test)+1); // get memory of same size
- for (int i=0; i<strlen(test); i++) // go through input
- *(coded+i)=*(test+i) + SHIFT; // write to output, + SHIFT
- *(coded+strlen(test))=0; // make sure have 0 at the end
- printf("Coded: %s\n",coded); // display it
- // Result: Coded: ]qr|)r|)j)|nl{n})vn||jpn
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment