sergey.lukoshkin@gmail.com kirjutas:
[...]
>
> Thanks a lot ! Now I call istr.clear() and it works properly.
> Here my fixed code.
>
> P.S I've never used boost lib.
>
You should, lots of it will be included in the next C++ standard.
>
> int main()
> {
> static std::string str;
> static std::istringstream istr;
> static unsigned val;
main() is called only once so the keyword 'static' does not change
anything here. Why do you think 'static' is needed?
And why do you define them here, not inside the loop where they are used?
Would have avoided all the trouble in the first place...
> while( true )
> {
> std::cout << "Enter num: " << std::endl;
> std::cin >> str;
>
> istr.clear();
> istr.str(str);
>
> istr >> val;
> std::cout << "Number: " << val << std::endl;
> }
>
> return 0;
>
> - Hide quoted text -
> - Show quoted text -
> }
>
Regards
Paavo