Quote Originally Posted by matsp View Post
And instead of making your own strcpy() implementation, why not use:
Code:
strcpy(wordArray[i], wordString);
Also, you don't free all the entries in wordArray, only the first allocation.

And there's another bug that both me and elysia missed: You are allocating strlen bytes, you need one more to store the zero at the end of the string.

--
Mats
When I do this...

Code:
	printf("i=%d    words=%d  \n", i, numWords-1);
	for(j = 0; j < numWords-1; j++) {
	  printf("%d: %s ", j, wordArray[j]);
	  for( i = 0; i < strlen(wordArray[j]); i++)
	    free(wordArray[j][i]);
	  free(wordArray[j]);
	}
I get this error...

Dict.c:69: warning: passing argument 1 of ‘free’ makes pointer from integer without a cast
I also added one extra byte for the \0.

Code:
	    wordArray[i] = (char*)checked_malloc(strlen(wordString)*sizeof(char)+1);