F
fudmore
Hello Everybody.
I have a Segmentation fault problem. The code section at the bottom
keeps throwing a Segmentation fault when it enters the IF block for the
second time.
const int WORDS_PER_LINE = 4;
when counter == 7 is when the string Concatenation fails within the IF
block.
BUT, the strange part is if the don't CLEAR the list ( // list.clear())
it works... but i'm afraid that I'm not freeing up memory when i
reassign different strings to the vector.
Code Snippet
---------------------------------------------------------------------------------------
while(str != NULL)
{
index = counter % WORDS_PER_LINE;
list[index] = *str;
cout << "i:" << index << " c:" << counter << " word : " << *str << endl;
if(index == (WORDS_PER_LINE-1))
{
string ref =
string("INSERT INTO BANKING(DATE,TRANS_TYPE,AMOUNT,BALANCE)
VALUES(TO_DATE('") +
list[0] +
string("','MM/DD/YYYY'),'") +
list[1] +
string("',") +
list[2] +
string(",") +
list[3]+
string(");");
cout << "processing .." << ref << endl;
list.clear();
}
counter++;
delete (str);
str = parser.readField();
}
I have a Segmentation fault problem. The code section at the bottom
keeps throwing a Segmentation fault when it enters the IF block for the
second time.
const int WORDS_PER_LINE = 4;
when counter == 7 is when the string Concatenation fails within the IF
block.
BUT, the strange part is if the don't CLEAR the list ( // list.clear())
it works... but i'm afraid that I'm not freeing up memory when i
reassign different strings to the vector.
Code Snippet
---------------------------------------------------------------------------------------
while(str != NULL)
{
index = counter % WORDS_PER_LINE;
list[index] = *str;
cout << "i:" << index << " c:" << counter << " word : " << *str << endl;
if(index == (WORDS_PER_LINE-1))
{
string ref =
string("INSERT INTO BANKING(DATE,TRANS_TYPE,AMOUNT,BALANCE)
VALUES(TO_DATE('") +
list[0] +
string("','MM/DD/YYYY'),'") +
list[1] +
string("',") +
list[2] +
string(",") +
list[3]+
string(");");
cout << "processing .." << ref << endl;
list.clear();
}
counter++;
delete (str);
str = parser.readField();
}