Witam,
Chce napisać program, który wyszukuje liczby w stringu np: mam stringa
7sqrt,
Program ma 7 zapisać do jakiejś zmiennej.
Jeszcze jest jeden przypadek, jak jest np 7.5sqrt, czyli liczba zmiennoprzecinkowa,
Jak napisać taki program,
Podsyłam kod, który mi się udało zrobić ale moja funkcja zawiesza cały program :(.
void SzukajLiczby2(string str)
{
long double ile_pierwiastkow2;
stringstream ss;
/* Storing the whole string into string stream */
ss << str;
/* Running loop till the end of the stream */
string temp;
long double found;
while (!ss.eof()) {
/* extracting word by word from stream */
ss >> temp;
/* Checking the given word is integer or not */
if (stringstream(temp) >> found)
ile_pierwiastkow2 = found;
/* To save from space at the end of string */
temp = "";
}
}