- 1
Hello, how can I randomly output two elements from the char array?
2 Réponses
+ 1
Remove line 20 and change line 21 to:
cout << c[rand() % 7] << " ";
So that the loop should look like:
for(int i=0; i<2; i++) {
cout << c[rand() % 7] << " ";
}
Works for me.
Note that rand() is from C language and it is recommended to use the <random> library in C++.
0
It works at me too. Thanks.