Segmentation Fault - Need assistance resolving {Novice C++ Programmer}
Hello folks, I seem to have recieved a segfault within my function but
am unsure on how to resolve it. I understand that it means that
somewhere something is trying to access memory that is not prohibited
or not available.
The following function is an overloaded += operator that reads in
strings in a record format seperated by comma delimiters except for the
last data which terminates with a semicolon. I am adding these records
to an array of objects which stores the record. I hope the folowing
code is enough to identify the problem. The static array's are defined
as told in my assignment.
const char* Bank::operator+=(const char a[])
{
char stringTemp[316];
char accountTemp[16];
int balanceTemp;
const char *ptr = a;
sscanf(ptr, "%15[^,],%d,%315[^;];", accountTemp, &balanceTemp,
stringTemp);
savings[size].changeAccountNumber(accountTemp);
savings[size].changeBalance(balanceTemp);
strcat(stringTemp,";");
savings[size].changeCustomerInfo(stringTemp);
size++; //Core dump here
return a;
}
- AMT2K5