#include <iostream>
#include <vector>
constexpr bool include_non_printable = false;
int main()
{
std::vector<int> possibilities;
for(int i=0; i<128; i++)
if(isprint(i) || include_non_printable)
possibilities.push_back(i);
srand48(time(0));
char pick = possibilities[lrand48()%possibilities.size()];
std::cout << "Random pick: "
<< (isprint(pick) ? std::string(1,pick) + " " : "")
<< "(" << (int)pick << ")"
<< std::endl;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: