A Collection of Code Snippets in as Many Programming Languages as Possible
This project is maintained by TheRenegadeCoder
Welcome to the Rot13 in C++ page! Here, you'll find the source code for this program as well as a description of how the program works.
#include <iostream>
#include <string>
using namespace std;
void rot13(string& str) {
for (char& c : str) {
if (('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z')) {
if (('a' <= c && c <= 'm') || ('A' <= c && c <= 'M')) {
c += 13;
} else {
c -= 13;
}
}
}
}
int main(int argc, char* argv[]) {
if (argc == 2 && string(argv[1]).size() != 0) {
string inputString(argv[1]);
rot13(inputString);
cout << inputString << endl;
} else {
cout << "Usage: please provide a string to encrypt" << endl;
}
return 0;
}
Rot13 in C++ was written by:
If you see anything you'd like to change or update, please consider contributing.
No 'How to Implement the Solution' section available. Please consider contributing.
No 'How to Run the Solution' section available. Please consider contributing.