/* * Copyright (C) 2014 Tomasz Kramkowski * * This program is free software. It is licensed under version 3 of the * GNU General Public License. * * You should have received a copy of the GNU General Public License * along with this program. If not, see [http://www.gnu.org/licenses/]. */ #include #include #include #include int main(int argc, char **argv) { if (argc != 3) { printf("Incorrect number of arguments.\n"); exit(1); } int rot = strtol(argv[2], NULL, 10); unsigned length = strlen(argv[1]); for (unsigned i = 0; i < length; i++) { if (isalpha(argv[1][i])) { if (argv[1][i] - 'A' < 26) putchar((argv[1][i] - 'A' + rot) % 26 + 'A'); else putchar((argv[1][i] - 'a' + rot) % 26 + 'a'); } else putchar(argv[1][i]); } putchar('\n'); return 0; }