I have tried Googling and trying everything I can think of, but I can't overcome the problem. So I have come to the masters at StackOverflow!
I am having trouble using the .at() string method:
std::string letters = "QWERTYUIO";
// &(letters.at(0)) now evaluates to QWERTYUIO
// &(letters.at(5)) now evaluates to YUIO
// etc.
What I want is the nth character of the string, not a string starting at the nth character.
I tried the [] operator, but I now have a new problem. The code is currently (using the Allegro library, but I don't think that is affecting this):
std::string letters = "QWERTYUIO";
char letter;
char StringY[5];
int row = 0;
for(int l = 0; l <= 2; ++l){
letter = letters[row + l];
textout_ex(buffer, font, &letter, l * 30, 20, makecol(255, 255, 255), -1);
sprintf(StringY, "%d", inventoryNum[row + l + 9]);
textout_ex(buffer, font, StringY, l * 30, 20, makecol(255, 255, 255), -1);
}
What is happening is the letter variable seems to be appending the StringY of the previous iteration to itself for no apparent reason. This is driving me insane.
Any help is appreciated.
Many thanks,
Will.