How could I read a text file and then find the numbers in it and convert them to int? Or is there a way to read them in as ints with out conversion? Thanks...
Printable View
How could I read a text file and then find the numbers in it and convert them to int? Or is there a way to read them in as ints with out conversion? Thanks...
if you are using streams....
int in;
stream >> in;
if not, look up the atoi() function.
open & check each character one by one. If a character is from '1' to '9' or '0' then load it up to memory until you come across to an invalid number e.g. letter or space. to convert it to int use atoi(), itoa does the reverce.
Hope that helps!
Thank you!