You can't use random that way. It may return the same values (that's how random works). What you need is random_shuffle
std::string[] names = {"A", "B", "C"};
std::random_shuffle(std::begin(names), std::end(names));
//now names are in random order. just iterate over them.