From: "John M. Aldrich" Newsgroups: comp.os.msdos.djgpp Subject: Re: Analizing profile / what's _doprnt Date: Sun, 10 May 1998 18:10:27 -0400 Organization: Two pounds of chaos and a pinch of salt. Lines: 35 Message-ID: <355625D3.2A45@cs.com> References: <35561e0b DOT 13598072 AT news DOT unisys DOT com DOT br> NNTP-Posting-Host: ppp131.cs.net Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Bruno Barberi Gnecco wrote: > > What is this _doprnt? Is there anything to do to improve it? > Another questions... Why fprintf and putc, if I use just the first one? > Would it be better to output char by char using putc (because the output is made > of string, generated a char a time) instead of fprintf("%s")? Or would be fast way > bufferize it? Is there a faster assembler function to substitute fprintf? _doprnt() is an internal libc function that is called by all the formatted print functions--printf(), fprintf(), sprintf(), vsprintf()--to actually format and store the output. There is a companion function _doscan() for the scanf() family of functions. _doprnt() is fairly complex, as you can see if you examine the library source code, so programs which use lots of formatted output can expect to spend a fair portion of time there. One other thing to remember is that the stdio output functions have to send their output through the DOS file stream mechanism, which requires a protected mode to real mode switch. In all, the printf() mechanism is not very fast or efficient. If you just want to output text, and don't need to use formatted output, it can be substantially faster to use puts(), etc. You can also reduce the size of your executable a great deal if you don't use any formatted output or input commands; the associated functionality is fairly large. As for why putc() is there, it's because _doprnt() calls putc() internally. -- --------------------------------------------------------------------- | John M. Aldrich | A singer in a smoky room / Smell of | | aka Fighteer I | wine and cheap perfume / For a smile | | mailto:fighteer AT cs DOT com | they can share the night / It goes | | http://www.cs.com/fighteer | on and on and on... | ---------------------------------------------------------------------