سؤال

I'm wondering if there is a way to avoid using a temporary string in this case:

tempString = inputString.substr(commaLast,commaCurrent-1);
yPos = strtod(tempString.c_str(), NULL);

There is no way to use the substr command and returning a c_str without first storing the substring in a temp string (supposing I dont want to modify the original string).

هل كانت مفيدة؟

المحلول

Have you tried the following?

yPos = strtod(inputString.substr(commaLast,commaCurrent-1).c_str(), NULL);
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top