I am trying to display "first", "among", "shift", "debug", and "craft" randomly, but it prints "shift" every time I run the project. In case this has anything to do with my problem, I'm using Xcode on macOS Ventura.
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main() {
vector <string> vec {"first", "among", "shift", "debug", "craft"};
int rand_num = rand() % vec.size();
string word;
word = vec[rand_num];
cout << word;
return 0;
}
I expected it to display "first", "among", "shift", "debug", or "craft" randomly, but it only printed "shift"