fork download
  1. #include <stdio.h>
  2. #include <cs50.h>
  3. #include <string.h>
  4. int main (int argc , string argv[])
  5. {
  6. string k = argv[1];
  7. if (argc != 2)
  8. {
  9. printf("Error, Enter one word made of alphabetical characters");
  10. return 1;
  11. }
  12. else
  13. {
  14. for (int i = 0, n = strlen(k); i < n; i++)
  15. {
  16. if (!((k[i] >= 'a' && k[i] <= 'z') || (k[i] >= 'A' && k[i] <= 'Z')))
  17. {
  18. printf("Error, Enter one word made of alphabetical characters");
  19. return 1;
  20. }
  21. }
  22. printf("plaintext:");
  23. string p = get_string();
  24. printf("ciphertext:");
  25. for (int j = 0 , i = 0, n = strlen(p); j < n; j++)
  26. {
  27.  
  28. if (i>= strlen(k))
  29. {
  30. i = 0;
  31. }
  32. int s = p[j] + k[i] - 'a';
  33. int c = p[j] + k[i] - 'A';
  34. if (k[i] >= 'A' && k[i] <= 'Z')
  35. {
  36. k[i] = k[i] + 32;
  37. }
  38. if ((p[j] >= 'a' && p[j] <= 'z' && s > 'z' ) || (p[j] >= 'A' && p[j] <= 'Z' && c > 'Z'))
  39. {
  40. printf("%c" , p[j] + k[i] - 'a' - 26);
  41. }
  42. else if ((p[j] >= 'a' && p[j] <= 'z') || (p[j] >= 'A' && p[j] <= 'Z'))
  43. {
  44. printf("%c" , p[j] + k[i] - 'a');
  45. }
  46. else
  47. {
  48. printf("%c" , p[j]);
  49. }
  50. i++;
  51. }
  52. printf("\n");
  53. return 0;
  54. }
  55. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function ‘main’:
prog.c:23:20: warning: implicit declaration of function ‘get_string’ [-Wimplicit-function-declaration]
         string p = get_string();
                    ^~~~~~~~~~
prog.c:23:20: warning: initialization makes pointer from integer without a cast [-Wint-conversion]
/home/hYpA06/ccuJFJzz.o: In function `main':
prog.c:(.text.startup+0x84): undefined reference to `get_string'
collect2: error: ld returned 1 exit status
stdout
Standard output is empty