We currently have some code to extract digits from an int, but I need to convert this to a platform without snprintf, and I am afraid of a buffer overrun. I have started to write my own portable (and optimized) snprintf but I was told to ask here in case someone had a better idea.
int extract_op(int instruction)
{
char buffer[OP_LEN+1];
snprintf(buffer, sizeof(buffer), "%0*u", OP_LEN, instruction);
return (buffer[1] - 48) * 10 + buffer[0] - 48;
}
We are using C strings because Speed is very important.