12345678910111213141516171819202122
string generateString(int length) { static const char alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; int strLen = sizeof(alphabet)-1; char genRandom; string str; srand(time(0)); for(int i=0; i<length; i++) { genRandom = alphabet[rand()%strLen]; str += genRandom; } return str; } int main() { string X, Y; X=generateString(10); Y=generateString(10); cout << X << endl << Y<< endl; }