I have made a txt file out of integers and chars that contains numbers and words.
When I read the file and get to a line that contains a number, I would like to put it into back into an integer.
How do i do this in c++?
The C standard library offers several conversion functions. [list=1][*][INLINECODE]strtol[/INLINECODE] - best error checking [[URL=http://www.daniweb.com/code/snippet441.html]demo[/URL]] [*][INLINECODE]sscanf[/INLINECODE] - some level of error checking [[URL=http://www.daniweb.com/code/snippet266.html]demo[/URL]] [*][INLINECODE]atoi[/INLINECODE] - poor level of error checking[/list]But for C++, I'd recommend looking into [URL="http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.2"]stringstreams[/URL]. Read More