Ok. So I have this function, init():
void init()
{
fstream file;
int index = 0;
char temp_list[60000][15];
listlen = 0;
current_index = 0;
file.open("en_US.dic");
while(!file.eof())
{
file >> temp_list[index];
index++;
}
listlen = index;
file.close();
file.open("en_US.dic");
word_list = new char*[listlen];
int count = 0;
for(int i = 0; i < listlen; i++)
{
word_list[i] = new char[21];
file >> word_list[i];
}
file.close();
}
This code compiles and runs correctly with no errors. However, when I change the line
word_list[i] = new char[21]
to
word_list[i] = new char[x] //x < 21
I get the following error:
dict: malloc.c:3074: sYSMALLOc: Assertion `(old_top == (((mbinptr) (((char *) &((av)->bins[((1) - 1) * 2])) - __builtin_offsetof (struct malloc_chunk, fd)))) && old_size == 0) || ((unsigned long) (old_size) >= (unsigned long)((((__builtin_offsetof (struct malloc_chunk, fd_nextsize))+((2 * (sizeof(size_t))) - 1)) & ~((2 * (sizeof(size_t))) - 1))) && ((old_top)->size & 0x1) && ((unsigned long)old_end & pagemask) == 0)' failed.
I'm somewhat new to programming (<2 years), and I've never seen anything like this. Anyone have any ideas? Thanks in advance!