Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!uwm.edu!bionet!agate!ucbvax!SLIC.CELLBIO.DUKE.EDU!jit From: jit@SLIC.CELLBIO.DUKE.EDU (Jit Keong Tan) Newsgroups: comp.sys.sgi Subject: (none) Message-ID: <9011262208.AA01163@slic.cellbio.duke.edu> Date: 26 Nov 90 22:08:17 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet Lines: 74 Subject: RE: Picture Specifications for UNIX I am not sure what does it mean by Picture Specifications. But the easiest way to write your own itoa function. so while calling printf function, insert your own itoa function. NOTE: I am writing the code as I think without any compilation, this is just to demonstrate how one can invent one's printf pattern. ------------------------------------------------------- char *itoa(int, char *,int); printf("Number = %d, Pretty number = %s \n", NUMBER_TO_PRINTED,itoa(NUMBER_TO_PRINTED, buffer, PRETTY_NUMBER)); where itoa() is : char *itoa(int number, char *buffer, int mode) { static char *ch; int pp; /******* Make sure buffer is large enough to hold the output format *******/ ch = buffer; switch (mode) { case PRETTY_NUMBER: pp = 0; do { pp++; *ch++ = number % 10 + '0'; /* works for ASCII */ if ( (pp % 3) == 0) *ch++ = ',';/* Add comma */ } while ( ( number /= 10) ); if (number < 0) *ch++ = '-'; *ch = '\0'; /* The number will come out reverse, and there will be one extra comma if the number is a multiple of 3 digits. But you get the idea, the correct version is left as an exercise. I don't feel like making my brains to work today :-) */ break; case BINARY: /* Print BINARY ! */ break; case ETC: /* Be innovative ! */ break; default : *ch = '0'; *++ch = '\0'; break; } return buffer; } -------------------------------------------------------- Jit Keong Tan | internet: jit@slic.cellbio.duke.edu (919) 684-8098 | bitnet : tan00001@dukemc.bitnet -------------------------------------------------------- U.S. Mail: Duke University Medical Center Department Of Cell Biology Box 3709 Durham, NC 27710