TIP: Click on subject to list as thread! ANSI
echo: cis.os9.68000.osk
to: all
from: Bob van der Poel 76510,2203
date: 1992-07-12 18:10:05
subject: #printf problem

 #: 15878 S12/OS9/68000 (OSK)
    12-Jul-92  18:10:05
Sb: #printf problem
Fm: Bob van der Poel 76510,2203
To: all

Has anyone else noticed a problem with the printf() family? The following code
fragement works fine by itself, but in a large program it doesn't:

   switch (fmt){
     .....
     case 'H': sprintf(buff,"%X",value);
               break;
     case 'h': sprintf(buff,"%x",value);
               break;

     ....

The entire format loop works fine--expect when the %X format is used. In this
case a single 'x' is printed. However, %x, does work alright. I've put a bunch
of debug code (printf()s) in the real program and the printf() react the same
way. For some reason, uppercase hex doesn't work. However, when I just extract
the code out and stick it in a test program, all works alright. I've really
pulled my hair on this one--even checked the crc while the program is running.
No luck. I've cobbled a work-around for now by using %x and then converting the
string to uppercase if fmt=='H'.

Either there is a bug in sprintf(), or my program is cobblering something. Any
ideas?

There is 1 Reply.

SOURCE: compuserve via textfiles.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.