strncat(result, &tempval, sizeof(tempval));
That's very wrong.

strncat is for strings. You should not take the address of a mundane character and expect it to work because the source should be...