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. for(i = 0; source[i] != '\0' && i < MAXLEN; i++) {
  9. destination[i] = source[i] + key;
  10. if(destination[i] > 125) {
  11. destination[i] -= 94;
  12. }
  13. }
  14. destination[i] = '\0';
  15. return 0;
  16. }
  17.  
  18.  
  19. int main(void) {
  20. char source[MAXLEN], destination[MAXLEN];
  21. int key;
  22. printf("Enter text to encrypt: ");
  23. scanf("%s",source);
  24. printf("Enter encryption key: ");
  25. scanf("%d",&key);
  26. cypher(source,destination,key);
  27. printf("Source:\n %s\nEncrypted:\n %s\n",source,destination);
  28. return 0;
  29. }
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty