💾 Archived View for sdf.org › aiden › src › rot13.c captured on 2023-06-14 at 14:27:07.

View Raw

More Information

⬅️ Previous capture (2021-12-03)

-=-=-=-=-=-=-

#include <stdio.h>

int
main(int argc, char *argv[])
{
  int i;
  char c, *str;

  str = argv[1];
  for (i = 0; str[i] != '\0'; ++i) {
    if (65 <= str[i] && 90 >= str[i]) {
      c = ((str[i] - 65 + 13) % 26) + 65;
      putchar(c);
    }

    if (97 <= str[i] && 122 >= str[i]) {
      c = ((str[i] - 97 + 13) % 26) + 97;
      putchar(c);
    }

    if (32 == str[i]) {
      c = str[i];
      putchar(c);
    }
  }
  putchar('\n');
  return 0;
}