I am trying to convert a string to a vector of ASCII value uint8_t
For example, if I have a string that is "500"
I would want a vector that is {53, 48, 48}
where these values are hex 0x35, 0x30, 0x30. This is what I am currently doing and it is not working
#include <iostream>
#include <string>
#include <vector>
int main() {
std::string number = "500";
std::vector<std::uint8_t> bytes;
for (auto& c : number)
bytes.push_back(static_cast<std::uint8_t>(c));
for (auto& c : bytes)
std::cout << c << std::endl;
return 0;
}
But I just get 5, 0, 0 as output where I was expecting 53, 48, 48