Re: Ascii Characters
e4me4m@gmail.com wrote:
This is a very dumb question... I have a std::vector<std::string> that
I'm pushing ascii charcters into like so:
set.push_back("a");
set.push_back("b");
'set' is not the best name for a vector. There is 'std::set', you know...
...
...
I'm doing this manually. This is error prone and time consuming. Does
something in the STL have these already? I'm rather new to C++ so
forgive me if this is blatantly obvious. Google did not help much. The
goal is to get all typable ascii chars into the vector.
I am not sure what is "a typable ascii", to be honest, perhaps you need
to do 'isprint' on those, but look into 'std::generate' or 'std::fill'.
There is a constructor of 'std::string' that takes the value and the
count, use it in a loop. Something like
for (char c = ' '; c <= '~'; ++c)
set.push_back(std::string(1, c));
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask