-2
所以,我想創建一個從數組中挑選簡單字符串的程序,對我來說聽起來很簡單,但後來我遇到了問題。這是我寫的:創建程序從數組中挑選出隨機字符串
int pickjob;
string jobs[] = {Police Officer, Fireman, Vet, Doctor, Nurse, Chemist, Waiter};
job1 = jobs[rand()%7];
job2 = jobs[rand()%7];
job3 = jobs[rand()%7];
cout << "Here i found some jobs for you, check them out\n1." << job1 << "\n2." << job2 << "\n3." << job3 << "\nGo Head and pick one out" << endl;
cin >> pickjob;
//Rest of code is below, i'll put it in if you need it ;)
但我的問題是,每次我運行該程序同樣的工作似乎每次(IM中C一amaetur ++,所以如果我聽起來很蠢見諒),讓我怎麼做一個計劃每次從陣列打印出不同的作業。
查看C++ 11及更高版本的''標頭。 –
Downvoter
在此之前你叫過srand()嗎? – NathanOliver
當我嘗試srand()它說一些錯誤一秒鐘lemme通過它 –