I have a std::stack like this:
stack<string> s;
I'm pushing single characters onto it and later want to retrieve the ASCII table value from the top of the stack. For example:
s.push("+");
cout << size_t(s.top());
I'm trying to get 43 to come out of this (43 is the ASCII value of the + sign), but I get an invalid conversion error on this. Anyone know why?
Thanks.
Well, that's because you pushing in std::string
s. Try pushing in char
s instead.
I was afraid you were going to say that. I'd have to re-write too much to make that conversion.
I got it to work like this:
cout << size_t(s.top()[0]);
Ugly, but effective.
Thanks!