fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. #define MAXLEN (50+1)
  5.  
  6. int cypher(char source[], char destination[],int key) {
  7. int i;
  8. char e;
  9. for(i = 0; source[i] != '\0' && i <= MAXLEN; i++) {
  10. if(source[i] == ' ') putchar(source[i]);
  11. e = ((source[i] - 32) + key) % 26;
  12. if(e > 94) {
  13. e -= 93;
  14. }
  15. destination[i] = e + 32;
  16. }
  17. destination[i] = '\0';
  18. return 0;
  19. }
  20.  
  21.  
  22. int main(void) {
  23. char source[MAXLEN], destination[MAXLEN];
  24. int key;
  25. printf("Enter text to encrypt: ");
  26. scanf("%s",source);
  27. printf("Enter encryption key: ");
  28. scanf("%d",&key);
  29. cypher(source,destination,key);
  30. printf("Source:\n %s\nEncrypted:\n %s\n",source,destination);
  31. return 0;
  32. }
  33.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty