I am reading one file and saving it in another file one character at a time. If I cout the character to the console I see what I want to save in a file as ascii characters, but I am unable to make the conversion.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
void copy_by_line(ifstream *ist, ofstream *ost)
{
vector<char>empty;
vector<char>temp;
while(*ist)
{
for(int i=0; i<163; ++i)
{
temp.push_back(ist->get());
}
for( int i =0; i<temp.size(); ++i)
{
*ost << temp[i]; // these characters are not always ascii
cout << temp[i]; // I want to save what I see here as an ascii character.
}
*ost << endl;
temp = empty;
}
}
Here is what it looks like in the source file which is also how it looks when I output it to cout:
1,Clamp,12.48,Workbench clamp
50,Flat Head Screwdriver,3.17,Flat head
75,Tire Bar,NULL,Tool for changing tires.
3000,3mm Bracket,0.52,NULL
edit:
Adding more clarification to my problem in hope of an answer. I have a very large csv file which I am unable to use. So I played with some test data and found that if I open the file in microsoft wordpad and save it as a text file I am able to use it. My problem is the actual file is too large to open so I am trying to write a utility program to produce this same result. What you see in my post above is a guess that is not working.
I'm not sure if this has anything to do with it or not but line 9 is calling get() repeatedly without checking for errors. Is the data really exactly 163 bytes?