   String to ints?
  I was adding some light styles to a game engine project (such as Strobe and Pulse) and was going to use an approach I saw elsewhere to add a custom flickering pattern.  The idea is that in the Light properties, artists enter a string of letters a-z that correspond to intensity (0-1).. so a=0/26 and z=26/26. Does anyone have any suggestions in how to extract each letter out of this string (maybe convert to a char[] first?) and how to get a letter to correspond to a number?Thanks!   
  Programming language?   ;  hah... whoopsmanaged C++ :)   ;  Knowing nothing about managed C++, here's an off the top of my head answer in just plain old C++, untested, but it should work://  storagestd::string strInput;std::cin >> strInput;std::vector<float> vecF;//  mosey through the stringfor (unsigned int ui = 0; ui < strInput.size( ); ++ui)   //  add to the vectora float    that is a char in the string   //scaled back to 0-25   //and divided by 25 (we want 'a'   //to be 0 and 'z' to be 1)vecF.push_back(static_cast<float>(strInput[ui] - 'a') / 25.0f);//  test what we gotfor (unsigned int ui = 0; ui < vecF.size( ); ++ui)std::cout << vecF[ui] << " ";std::cout << std::endl;I can explain more fully, but it's pretty straightforward.  Any specifically managed C++ solutions, anyone?   ;  thanks joule,  i'll give that a shot!   ;  Um, no. That's how you'd do it in C. In C++ you'd use stringstreams (I cbf finding a link), but Boost* has already got a perfectly good implementation (better than you could make in a week! I know, I tried!).Try this instead:#include <boost/lexical_cast.hpp>int main(){std::string str = "654";int i = boost::lexical_cast<int>(str);std::string str2 = "89.5";float f = boost::lexical_cast<float>(str);}*There's a link to Boost in my signature.   ;  Suggestion: I'm thinking sometime down the road you'll be wanting to also control duration in addition to intensity. How about a syntax like this (for example): "<intensity>:<duration>,<intensity>:<duration>,...".Example:"a:10,f:2,d:5,c:2"You can then easily parse this with the string.split method, once for ',' to get each step and then for ':' to separate intensity from duration. As for letter to number you can either have some conversion table, or perhaps you can do some tricks with the decimal ASCII codes. Get the int cast of char 'a' and subtract that from the char value of the intensity letter.   ;  just for reference, the string stream method is as follows:#include <sstream>std::stringstream ss1, ss2;int i;float f;ss1 << "63";ss1 >> i;ss2 << "654.213";ss2 >> f;(NOTE: reusing stringstreams gets a bit annoying which is why I just instantiate two)   ;  I have to say, a-z is a very unnatural way to express intensities, can't you just use delimited numbers?   ;  thanks for the help guysOmid: that seems like a good idea, i'll have a look at that!Jerax: i had a think about using numbers (&/or delimiters)... but I opted for setup speed. Having to enter delimiters each intensity when setting the light up isn't as fast as mashing the keyboard and using letters! :P   I'll try a few ways though... see which feels smoothest to work with.   