I have this code:
std::vector <int> loc;
loc.push_back(cpx);
loc.push_back(cpy);
loc.push_back(play.GetSize().x);
loc.push_back(70);
std::cout<<loc[3];
in a game I am making but even when I print the value of loc[2] and loc[3] they are completely different than they should be, when I run this code I get loc[3] equaling 70070 instead of 70. Does anybody know how to fix this?
You have another cout without an endl or \n somewhere in your code that you forgot to remove. That one prints the 700, while the 70 is the correct output of the last line in your code sample.
Change your last line to std::cout<< " and loc[3] is: " << loc[3] << std::endl; to see that my wild guess is right, then go hunting for that other cout.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With