I was bored this morning so made this ROT13... uh... thing?

Feel free to yell at me for doing stuff wrong :nana-thumb:
#include <iostream>

int main() {
    char alp[26] = {'a','b','c' ,'d' ,'e' ,'f' ,'g' ,'h' ,'i' ,'j' ,'k' ,'l' ,'m' ,'n' ,'o','p' ,'q' ,'r' ,'s' ,'t' ,'u' ,'v' ,'w' ,'x' ,'y','z'};
    int c; //The offset amount
    std::string t; //actual word
    std::string n; //the ROT13 string

    std::cout << "Choose Offset: ";
    std::cin >> c;
    std::cout << "Type your word: ";
    std::cin >> t;

    for (int i = 0; i < t.length(); i++) {
        for (int w = 0; w < sizeof(alp); w++) { //loop through all 26 character of alphabet
            if (t[i] == alp[w]) { //when you find a match for the character
                if (w + c > 26) { //if the current is over the alphabet limit
                    int new_char = w + c - 26;
                    n = n + alp[new_char];
                else { //if it is not
                    int new_char = w + c; //do the math and give number

                    n = n + alp[new_char]; //add to string

    std::cout << n;
    return 0;


think about it could make the 13 a variable and have you choose the offset.. so I did that


ah just realised it doesn't work with upper case letter. Oops
Last edited: