I have a program with the intention of parsing a downloaded html document to a csv, but the html has incomplete carriage returns, instead of having 0Ah0Dh (or 0x0A,0x0D) it has one or the other. This screws with any fstream functions, so I'm attempting to replace all instances of 0x0A and 0x0D with 'L'.
However, about a quarter through the file, the badbit gets set (the file is just under 40,000 characters long)
here is the function that is misbehaving.
/* getFileLength is a custom function that does just that */
If it's just a carriage return you want, why not just replace each '0x0A and 0x0D' with "\r" ?
I think there's a problem with flush since the badbit will get set when flush fails. It may be possible to call flush too often but I don't know enough about it...
could u try something like this without the need to call flush (pseudo code):
1 2 3 4 5 6 7 8 9 10
int start;
while(file)
{
getline(file, strdata, delimiter);
find(0x0A | 0x0D)
if(start != string::pos)
{
replace(0x0A | 0x0D with 'L' in file by using the 'start')
}
}