1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
stringstream newFC (stringstream::in|stringstream::out);
fileContents.seekg(0,ios::beg);//Move the get pointer to the beginning of the stringstream
fileContents.clear();//Reset the flags only
while(!fileContents.eof())
{
getline(fileContents,buffer,',');
string buffer;
getline(fileContents,buffer,',');
buffer.resize(buffer.size());//trim the strings for an accurate comparison
if(buffer.compare(name) == 0)//name is a string passed into my function
{
getline(fileContents,buffer,',');
getline(fileContents,buffer,'\n');
count--;
}
else
{
newFC << buffer << ',';
getline(fileContents,buffer,',');//Remove the second column associated with name
newFC << buffer << ',';
getline(fileContents,buffer,',');//Remove the third column associated with name
newFC << buffer << ',';
}
}
fileContents.str() = newFC.str();
|