hmm... if curPos points to the the next available position in the array, than I would do this. curPos + 1 points after the current '\0' termination of ans, since arrays in C are indexed starting at 0.
if (i % 8 == 0 && i != 0)
{
ans[curPos++] = '\n';
ans[curPos] = '\0'; /* always null terminate a string after any extension */
}