Subj : Re: Fixed-width data reading from FILE/streams To : borland.public.cpp.borlandcpp From : Bob Gonder Date : Sun Feb 08 2004 05:14 pm José Mauro Marinho wrote: >but not so simple, why int and float must be read also. But is _is_ that simple. Text is Text. > 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) ; >Moreover, it shall recognize the implicit decimal point for float columns, >eg. 1035 => 1.035 (%4.3f ?) if( '.' != record.secondval[2] ) Val2 /= 1000.0; Or manipulate the strings to add the decimal before doing atof(). .