Subj : Re: Fixed-width data reading from FILE/streams To : borland.public.cpp.borlandcpp From : maeder@glue.ch (Thomas Maeder [TeamB]) Date : Mon Feb 09 2004 08:49 am Bob Gonder writes: >> For instance, here is two typical lines: >> >>0091 This is a test 4.56 1.03 >>0096 This also.. 1035 > > And those numbers aren't integers or floats, they are text strings. > If you want to treat them as numbers, you need to convert them from > strings into numbers. > > int Val1 = atoi(record.firstval); > float Val2 = atof(record.secondval) ; The Standard C and C++ Libraries have better replacements of the ato* functions: strtol, strtoul, strtof, strtod. They are better because they allow the caller to detect parsing failures. .