ROT47 Implementation
#include &lt;cstring&gt;
#include &lt;cstdio&gt;


You're not using either of those, so remove them, and include &lt;string&gt; instead to get std::string.

std::string rot47(std::string s) { /* ... */ }


Why copy the caller's string? You're only reading from it, so take it by const&amp;.

std::string s1 = "!\"#$%&amp;\...";
std::string s2 = "PQRSTUVW...";


These two are constant, don't allocate them for every call, make them static (and const):

static std::string const s1 = "...";




std::string ret = "";


That initialization is not necessary, a default-constructed string is empty. You might want to reserve the appropriate size since you know it though, for optimal performance.

for (unsigned int i = 0; i &lt; s.size(); i++) { /* ... */ }


You can use range-based for loop with strings:

for (auto c: s) { /* ... */ }


And you should probably check that s1.find actually found something, otherwise the line after that is undefined behavior.

And s, s1 and s2 are rather poor choices for those variable names. Something like "source", "original", "plaintext" for the input would be better. map_from / map_to could work for the other two.