Subj : Re: Fixed-width data reading from FILE/streams To : borland.public.cpp.borlandcpp From : Bob Gonder Date : Sun Feb 08 2004 12:00 pm José Mauro T. Marinho wrote: >Can somebody tell me in a nutshell what is the best way to read fixed-width >(column delimited) data from a text file. Incredibly, Fortran is very best >C/C++ in this tedious task... First, open the text file in binary mode, not text. Define a structure that matches your data. typedef struct rec{ char FirstPart[10]; char SecondPart[27]; char crlf[2]; }MYRECORD; MYRECORD record; Use your choice of file functions to open the file in binary mode. Then use the matching read function to read( file, &record, sizeof(MYRECORD) ) If your file has cr/lf delimiting the records, don't forget to include room in your structure for it. .