#include "stdafx.h"
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <ctime>
#include <string>
usingnamespace std;
int main()
{
int random;
int ans;
int turn;
constint sheep = 5;
string color[sheep] = {"Brown", "White", "Green", "Yellow", "Blue"};
cout<<"Press 1 to start"<<endl;
cin >> ans;
do{
srand (time(0));
random = (rand()%5) + 1;
}while (ans == 1);
}
cin.get();
cin.get();
return 0;
}
This is only the first part of the code, so i have unfinished functions and Ive included lots of libraries I dont need. But My compiler says cin is ambiguous and return expected a function. No idea why it isnt working. Any help pleasee?
int random;
int ans;
int turn;
const int sheep = 5;
string color[sheep] = {"Brown", "White", "Green", "Yellow", "Blue"};
cout<<"Press 1 to start"<<endl;
cin >> ans;
do{
srand (time(0));
random = (rand()%5) + 1; printf(" \n\ninside the fnc - ans = %d ", ans );
cin >> ans;
}while (ans == 1);
It's hung in the loop. Once you give it '1' then it stays 1 forever.
so I added these two lines ( only the " cin >> ans; " is required )
so that when finished, it asks for a new value, like NOT 1.
Printf statements ( and other similar flags) are Always useful to tell where I am and what the values being returned are the values expected.