Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #define N 20
- void encoder(char text[], char *enc_text)
- {
- int i, j;
- int len = strlen(text);
- char alphabet[27] = { 'a','b','c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'Z' };
- for (i = 0; i < len; i++)
- {
- for (j = 0; j < 27; j++) {
- if (text[i] == alphabet[j])
- {
- enc_text[i] = alphabet[j + 1];
- }
- }
- }
- enc_text[i] = '\0';
- }
- int main()
- {
- FILE *file;
- if ((file = fopen("shif_text.txt", "a")) == NULL)
- {
- printf("fail");
- getchar();
- return ;
- }
- char *text;
- char *encode_t;
- text = (char*)malloc(sizeof(char)*N);
- gets(text);
- encode_t = (char*)malloc(sizeof(char)*N);
- encoder(text, encode_t);
- fputs(encode_t, file);
- fclose(file);
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement