Reputation: 3
Hello world of stackoverflow, currently, i have a problem, im working on a school project for c++, to reset a high score file, however, when compiling, the compiler always shows this error:
error C2679: binary '>>' : no operator found which takes a right-hand operand of type 'std::string [100]' (or there is no acceptable conversion)
so, after tons of googling, nothing works, so i just came here
here's my header:
//Include Libraries
#include <iostream>
#include <string>
#include <fstream>
#include <vector>
#include <istream>
#include <string.h>
//use namespace std
using namespace std;
i clearly include string, iostream, fstream, and anything else i should need to include
here's my code:
void reset ()
{
//Declare Local Variables
int High_Score[5];
bool defualt;
char User_Reset = false;
string YN[100];
string High_Score_Name[5];
int Rank;
//Initialize a high score at 0
High_Score[4] = 0;
// Input the high scores from a file
ifstream Input_High_Scores;
Input_High_Scores.open ("High_Scores.txt");
for (int i = 0; i < 5; i++)
{
Input_High_Scores >> High_Score[i];
Input_High_Scores >> High_Score_Name[i];
}
Input_High_Scores.close ();
//Welcome and ask the user if he wants to see high scores before resseting
cout << "Welcome to the High Score Reset Software" << endl;
cout << "Would you like to see your high scores before resettings? (0 for no, 1 for yes)" << endl;
cin >> YN;
}
Upvotes: 0
Views: 156
Reputation: 992707
string YN[100];
Here you are declaring an array of 100 strings. That's probably not what you wanted. Try:
string YN;
The error message you got is referring to the line
cin >> YN;
where, if YN
is an array of 100 strings, the >>
operator has no idea what you want to do. However, >>
knows how to read one string.
Upvotes: 1