I have been trying to work on my own and simple encrypting tool. My logic is that when the user enters the correct key work and key pin, the correct answer shows up. But on the other end, if it is the incorect word, then they answer is a bunch of random characters as the program went to the wrong places to get it.
Now to do so, I have tried to use string.at()
to access the specific letters and then assign them to number so that i can use them as coordonates to find the various charachters in the board using arrays that have two parameters(Array[x][y]
).
My code :
cout << "mot de 8 lettres: ";
cin >> EighLettreWrd;
cout << "nombre de 4 chiffres: ";
cin >> Pin;
int XCoor[8];
int YCoor[8];
string LetterDatabase[26] = { "a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z" };
for (int y = 1; y <= 8; y++)
{
for (int l = 1; l <= 26; l++)
{
//This is where I get the error messages
if (EighLettreWrd.at[y] == LetterDatabase[l])
{
YCoor[y] = l;
}
}
cout << YCoor[y] << endl;
}
The error I get :
Severity Code Description Project File Line Suppression State Error C3867 'std::basic_string,std::allocator>::at': non-standard syntax; use '&' to create a pointer to member Main c:\users\jonat\onedrive\documents\visual studio 2017\projects\algorithme\main\algo.cpp 210
What I have tried :
- I have tried to put () instead of [] at
EightLetterWrd.at
but then I get this error : Severity Code Description Project File Line Suppression State Error (active) E0349 no operator "==" matches these operands Main c:\Users\jonat\OneDrive\Documents\Visual Studio 2017\Projects\Algorithme\Main\algo.cpp 210 - I tried to set the char into a string to try to avoid the "no operand match" but it simply moved the convertion from char to string issue just couple lines higher
- I've looked up these errors on google but none seems to be using a & to make a pointer and I don't where to put this sign so that it stop this error message from showing.
... I think that's about it for the explanation of the situation.
Thank you very much for your patience concerning the lenght of this message.
Aucun commentaire:
Enregistrer un commentaire