+ 1

Vector question

Ok, so I'm trying to make a vector that fills with user input. https://code.sololearn.com/cO1Tdr5in85S/?ref=app However, it seems to fill with incorrect values. I'm thinking it's because any values entered are technically strings, but I'm not sure. I won't have time to test anything for a bit, so that's why I'm posting this. I think I remember seeing methods to change one data type to another, but I could be wrong. But if I'm right, could it be a possible solution?

15th Feb 2019, 10:28 PM
Daniel Cooper
Daniel Cooper - avatar
1 Antwort
+ 1
If you convert a char into an int, it will be the ascii number of that char. So if you write the digit '4' it will become 52. If you want to do it raw, just subtract 48 from each digit, as you push it into your vector, and you should get what you expect.
15th Feb 2019, 10:35 PM
HonFu
HonFu - avatar