I am using clang++ "file.cpp" -std=c++14 -Weverything -Wno-c++98-compat to compile my program. Now I get this following error code:
warning: implicit conversion changes signedness: 'int' to 'unsigned long' [-Wsign-conversion]
The error line is this:
v_rand = rand() % (english.size());
The whole code of error:
void trainer_es (string lang)
{
ifstream in("dictionary_es.txt");
if(!in)
{
cout<<"ERROR"<<endl;
}
string line;
int right=0;
int wrong=0;
vector<string> english, spanish;
bool is_english = true;
while(in.eof()==0)
{
getline(in,line);
if(is_english
{
english.push_back(line);
}
else
{
spanish.push_back(line);
}
is_english = !is_english;
}
in.close();
unsigned long v_rand;
srand(unsigned (time(nullptr)));
if (lang == "english")
{
for (unsigned long int i=0; i<deutsch.size()-1; i++)
{
v_rand = rand() % (english.size());
cout<<"Translate the word: "<<english.at(v_rand)<<endl;
cin>>line;
if(line == spanish.at(v_rand))
{
cout<<"right!"<<endl;
right++;
}
else
{
cout<<"wrong"<<endl;
cout<<"the correct word is: "<<spanish.at(v_rand)<<endl;
wrong++;
}
}
}
Thanks for your help