I know this is late but I would just like to add in case of any future viewers that
snprintf is c99 and sprintf is specified in c90. Due to portability I was required to use c89 and hence did not use them originally.My fault for leaving it out the question, sorry.