Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

fstream and missing commas

Status
Not open for further replies.

RhinomanUK

Technical User
May 14, 2007
1
GB
Hi
I'm not entirely sure where my problem lies. I am using BCB6 Personal v6. I am reading a csv file using fstream. It is code that I have used before but this time I don't get the commas in the data read in. Another programme using the same code compiles and runs correctly. The only difference seems to be that the code that doesn't work corrrectly won't compile without Classes.hpp included.
I have tried opening the file in both binary and text modes, this makes no difference (in either case). The code that reads in the data is:

Code:
unsigned char FileHandler::getChar(int position)
{
        FileHandlerFile.seekg(position,ios::beg);
        FileHandlerFile.read(reinterpret_cast<char*>( &inData ),1);    //retrieve one character at a time
        return inData;
}

TIA
James


 
bleh..

use a TStringList to read the file in.

then use a separate TStringList and set the value of CommaText to each line in the first. Now you have a neat array of every element for each line.



Hope this helps!

Regards

BuilderSpec
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top