void Psprintf(char *outBuf,const char *inFormat,...) { va_list theVA; int theI; char *theCp; char theCb[16]; static char theN[] = "0123456789ABCDEF"; va_start(theVA,inFormat); while(*inFormat){ if(*inFormat == '%'){ switch(*(inFormat+1)){ case 'c': theI = va_arg(theVA,int); if(isprint(theI)){ *outBuf++ = (char)theI; }else{ *outBuf++ = '?'; } inFormat += 2; break; case 'd': theI = va_arg(theVA,int); if(theI < 0){ *outBuf++ = '-'; theI *= -1; } theCp = theCb; while(theI >= 10){ *theCp++ = theN[theI % 10]; theI /= 10; } *theCp++ = theN[theI]; while(--theCp >= theCb){ *outBuf++ = *theCp; } inFormat += 2; break; case 's': theCp = va_arg(theVA,char *); while(*theCp){ *outBuf++ = *theCp++; } inFormat += 2; break; case 'x': theI = va_arg(theVA,int); if(theI < 0){ *outBuf++ = '-'; theI *= -1; } theCp = theCb; while(theI >= 16){ *theCp++ = theN[theI % 16]; theI /= 16; } *theCp++ = theN[theI]; while(--theCp >= theCb){ *outBuf++ = *theCp; } inFormat += 2; break; case '%': *outBuf++ = '%'; inFormat += 2; break; default: *outBuf++ = *inFormat++; break; } }else{ *outBuf++ = *inFormat++; } } *outBuf = '\0'; va_end(theVA); }