You have allocated the array of poitners rowptr, but not the elements of each row. As a result, your strcpy() functions will be corrupting memory. You also need to do this:
for (row = 0; row < nrows; row++)
{
rowptr[row] = (char*)calloc(ncols, sizeof(char));
}
As mentioned, you also need to change the type of rowptr to a char** instead of an int**, and change the allocateion to rowptr = (char**)malloc(nrows*sizeof(char*)); or rowptr = (char**)calloc(nrows, sizeof(char*));
rubberman
Posting Maven
2,578 posts since Mar 2010
Reputation Points: 365
Solved Threads: 307
Skill Endorsements: 52
Question Answered as of 10 Months Ago by
sepp2k,
rubberman
and
Sokurenko