I am currently using the following code to convert a string (or part of it) into an integer:
This code will put the integer value into temp. It will also disregard any alpha characters after the int.Code:string myString; ...... int temp = 0; sscanf(myString.c_str(), "%d", &temp);
I realise that this is a bit of a mix of C and C++. Is there a better way to do this in C++? Or do I need to convert it to a C string first??