+ 1

THERE IS NO <ARRAY> LIBRARY IN 2008 CPP. PLEASE HELP!

PLEASE HELP ME ON THIS 😢

23rd May 2017, 12:31 PM
eiro Jan
eiro Jan - avatar
31 Antworten
+ 2
Well, Ill make it c++98 compatible... Will that work?
23rd May 2017, 12:34 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 1
can you make it happen so i can put it on visual studio 2008? 😢
23rd May 2017, 12:34 PM
eiro Jan
eiro Jan - avatar
+ 1
@kinshuk my prof did not accept it cause it didnt run on visual 2008 😢😢
23rd May 2017, 12:35 PM
eiro Jan
eiro Jan - avatar
+ 1
Sure! But Please add stdafx.h later if you have selected precompilation...
23rd May 2017, 12:35 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 1
i'm so dead if your bot there to help 💔
23rd May 2017, 12:37 PM
eiro Jan
eiro Jan - avatar
+ 1
#include <iostream> //#include "stdafx.h" //This is a specific project requirement #include <ctime> #include <cstdlib> #include <string> //Forgot this, maybe this is why array didn't work? using namespace std; int main() { cout <<"======THE TURTLE RACE======"<<endl; const int numberOfTurtles = 4; string turtle[4]; //Just changed this... srand(time(NULL)); cout << "PLACE YOUR BET HERE!"; cout << "\n\nEnter your name on your turtle!\n\n"; for(int i = 0; i < 4; i++){ cin >> turtle[i]; } int winner; // here will chose the winner winner = rand() % numberOfTurtles; int secondPlace; int thirdPlace; int fourthPlace; bool foundSecond = false; bool foundThird = false; bool foundFourth = false; // here we get the second place while(!foundSecond) { secondPlace = rand() % numberOfTurtles; if(secondPlace != winner) foundSecond = true; } // here we get the third place while(!foundThird ) { thirdPlace = rand() % numberOfTurtles; if(thirdPlace != secondPlace && thirdPlace != winner) foundThird = true; } // here we get the fourth place while(!foundFourth ) { fourthPlace = rand() % numberOfTurtles; if( fourthPlace != secondPlace && fourthPlace != winner && fourthPlace != thirdPlace ) foundFourth = true; } cout << "Winner: " << turtle[winner] << endl; cout << "Second place: " << turtle[secondPlace] <<endl; cout << "Third place: " << turtle[thirdPlace] <<endl; cout << "Fourth place: " << turtle[fourthPlace] <<endl; cout << "\nCONGRATULLATIONS! "<< turtle[winner]<<endl; cout << "Your turtle has won and your money has beed doubled!\n"; cout << "TRY AGAIN AND BE RICH!" <<endl; return 0; }
23rd May 2017, 12:38 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 1
Please try this and tell me...
23rd May 2017, 12:39 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 1
I have Visual Studio 2015, so it may still be a problem...
23rd May 2017, 12:40 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 1
Now what happened?
23rd May 2017, 12:52 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 1
Did you try running it?
23rd May 2017, 1:36 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 1
Ok...
23rd May 2017, 1:47 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 1
stdafx.h, not sdhfx.h
23rd May 2017, 2:02 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 1
or try without that...
23rd May 2017, 2:03 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 1
Or if you don't want the program to end... int age; cout<<"Enter your age, Sir...";cin>>age; while(age<18) { cout<<"You're not eligible..., Try again..."<<endl; cout<<"Enter your age, Sir...";cin>>age; }
23rd May 2017, 2:08 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 1
I suggest you create a new project, win32 console app, and mark the precompiled header checkbox on the page which has the finish button. then add your code in the new cpp file created, without removing stdafx.h or windows.h from it...
23rd May 2017, 2:15 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 1
@kinshuk I'll try to finish this tomorow 😊
23rd May 2017, 2:19 PM
eiro Jan
eiro Jan - avatar
0
#include <iostream> #include <array> #include <ctime> #include <cstdlib> using namespace std; int main() { cout <<"======THE TURTLE RACE======"<<endl; const int numberOfTurtles = 4; array<string,4> turtle; srand(time(NULL)); cout << "PLACE YOUR BET HERE!"; cout << "\n\nEnter your name on your turtle!\n\n"; for(int i = 0; i < 4; i++){ cin >> turtle[i]; } int winner; // here will chose the winner winner = rand() % numberOfTurtles; int secondPlace; int thirdPlace; int fourthPlace; bool foundSecond = false; bool foundThird = false; bool foundFourth = false; // here we get the second place while(!foundSecond) { secondPlace = rand() % numberOfTurtles; if(secondPlace != winner) foundSecond = true; } // here we get the third place while(!foundThird ) { thirdPlace = rand() % numberOfTurtles; if(thirdPlace != secondPlace && thirdPlace != winner) foundThird = true; } // here we get the fourth place while(!foundFourth ) { fourthPlace = rand() % numberOfTurtles; if( fourthPlace != secondPlace && fourthPlace != winner && fourthPlace != thirdPlace ) foundFourth = true; } cout << "Winner: " << turtle[winner] << endl; cout << "Second place: " << turtle[secondPlace] <<endl; cout << "Third place: " << turtle[thirdPlace] <<endl; cout << "Fourth place: " << turtle[fourthPlace] <<endl; cout << "\nCONGRATULLATIONS! "<< turtle[winner]<<endl; cout << "Your turtle has won and your money has beed doubled!\n"; cout << "TRY AGAIN AND BE RICH!" <<endl; return 0; }
23rd May 2017, 12:31 PM
eiro Jan
eiro Jan - avatar
0
this is my code, can someone convert this to a code with no array but same output? rhabks
23rd May 2017, 12:31 PM
eiro Jan
eiro Jan - avatar
0
how sir? can you teach me later how? thabk you very much sir 😣
23rd May 2017, 12:36 PM
eiro Jan
eiro Jan - avatar
0
@kinshuk thank you sir 😣😣 please help me this day, I rwally need someone right now. I'm so brokw
23rd May 2017, 12:49 PM
eiro Jan
eiro Jan - avatar