Hi.
Im trying to malloc memory so that I can create an array of characters, making a word, but when the execution gets to my malloc line, it complains hardcore. (This is C btw, not C++)
Here is the portion of code it gets too, and here is the output dump it gives. Any ideas?:
counter = 0;
nullChecker = 1;
while( nullChecker != 0 )
{
nullChecker = wordArray[codeWord+offset+counter+1];
counter++;
}
printf("counter value: %d\n",counter);
// execution gets here, setting counter to 6 (observed from printf above)
unsigned char *string = malloc(counter + 1);
// using gdb, the program gets here, and suddenly breaks after executing the previous line...
int k;
for(k = 0; k < counter; k++){
unsigned int letterTmp;
letterTmp = wordArray[codeWord+offset+k+1];
printf("string: $s", letterTmp);
string[k] = (char)letterTmp;
}
Bookmarks