It also shouldn't be necessary to have the "q[n] = '\0'" either - as the calloc returns an array already zeroed.
strncpy cannot add a null on its own unless the string copied is less than n bytes - the problem is that there just might not be an allocation of n+1 bytes in all cases...
|