Click here to Skip to main content
15,892,927 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Trouble in writing a CRC CCITT program Pin
kakan17-Oct-05 20:13
professionalkakan17-Oct-05 20:13 
GeneralRe: Trouble in writing a CRC CCITT program Pin
LaHaHa17-Oct-05 21:07
LaHaHa17-Oct-05 21:07 
GeneralRe: Trouble in writing a CRC CCITT program Pin
kakan18-Oct-05 0:07
professionalkakan18-Oct-05 0:07 
GeneralRe: Trouble in writing a CRC CCITT program Pin
LaHaHa18-Oct-05 5:52
LaHaHa18-Oct-05 5:52 
GeneralRe: Trouble in writing a CRC CCITT program Pin
Kythen18-Oct-05 11:17
Kythen18-Oct-05 11:17 
GeneralRe: Trouble in writing a CRC CCITT program Pin
LaHaHa18-Oct-05 14:25
LaHaHa18-Oct-05 14:25 
Questionhow to adjust printing size of OnFilePrint() function {CView } ; Pin
vikas amin17-Oct-05 20:04
vikas amin17-Oct-05 20:04 
QuestionHelp -- something faster than Getline() ?? Pin
webHamlet17-Oct-05 19:51
webHamlet17-Oct-05 19:51 
Hi --

I find getline() function to be extremely slow when reading data from a text file. I tried replacing getline with a homemade function called getChunk (shown below) but it's just as slow.

getChunk(std::istream &in, std::string &s, const char terminator)
{
s.erase(s.begin(),s.end()) ;
s.reserve(10) ;
std::string::value_type ch ;
while (in.get(ch) && ch != terminator)
s.insert(s.end(),ch) ;
}

For context, here's the core of my program:

rawData.reserve(numberRecords) ;
int counter=0 ;
do
{
counter=counter+1 ;
std::vector <std::string> record ;
record.reserve(numberVars) ;
for(int i=0; i<numbervars-1; i++)
="" {
="" getchunk(*data,value,',')="" ;
="" std::getline(*data,value,',')="" record.push_back(value)="" }
="" getchunk(*data,value,'\n')="" std::getline(*data,value)="" rawdata.push_back(record)="" ;=""
="" std::vector="" <="" std::string="">::iterator j ;
j=record.begin() ;
record.erase(j, j+numberVars) ; } while (counter < numberRecords) ;
numberRecords=rawData.size() ;

Can anyone help me out here?

Thanks,



Kim Larsen
AnswerRe: Help -- something faster than Getline() ?? Pin
The NULL Developer17-Oct-05 21:03
professionalThe NULL Developer17-Oct-05 21:03 
GeneralRe: Help -- something faster than Getline() ?? Pin
Anonymous18-Oct-05 6:41
Anonymous18-Oct-05 6:41 
AnswerRe: Help -- something faster than Getline() ?? Pin
kakan18-Oct-05 1:19
professionalkakan18-Oct-05 1:19 
GeneralRe: Help -- something faster than Getline() ?? Pin
Anonymous18-Oct-05 6:40
Anonymous18-Oct-05 6:40 
GeneralRe: Help -- something faster than Getline() ?? Pin
kakan18-Oct-05 19:23
professionalkakan18-Oct-05 19:23 
QuestionUse Sockets in a DLL Pin
tobeymag17-Oct-05 19:27
tobeymag17-Oct-05 19:27 
AnswerRe: Use Sockets in a DLL Pin
xxrl17-Oct-05 20:23
xxrl17-Oct-05 20:23 
GeneralRe: Use Sockets in a DLL Pin
tobeymag18-Oct-05 19:20
tobeymag18-Oct-05 19:20 
GeneralRe: Use Sockets in a DLL Pin
xxrl19-Oct-05 19:16
xxrl19-Oct-05 19:16 
QuestionCould you help me with Rich Edit? Pin
Reunion17-Oct-05 19:25
Reunion17-Oct-05 19:25 
QuestionRe: Could you help me with Rich Edit? Pin
David Crow18-Oct-05 3:30
David Crow18-Oct-05 3:30 
AnswerRe: Could you help me with Rich Edit? Pin
Reunion18-Oct-05 18:22
Reunion18-Oct-05 18:22 
GeneralRe: Could you help me with Rich Edit? Pin
David Crow19-Oct-05 2:46
David Crow19-Oct-05 2:46 
GeneralRe: Could you help me with Rich Edit? Pin
Reunion19-Oct-05 17:20
Reunion19-Oct-05 17:20 
QuestionRe: Could you help me with Rich Edit? Pin
David Crow20-Oct-05 4:21
David Crow20-Oct-05 4:21 
AnswerRe: Could you help me with Rich Edit? Pin
Reunion20-Oct-05 18:12
Reunion20-Oct-05 18:12 
QuestionRe: Could you help me with Rich Edit? Pin
David Crow21-Oct-05 3:15
David Crow21-Oct-05 3:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.