Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!lll-winken!ncis.tis.llnl.gov!dog.ee.lbl.gov!nosc!manta!mitch From: mitch@manta.NOSC.MIL (Ray Mitchell) Newsgroups: comp.std.c Subject: ANSI printf Keywords: printf Message-ID: <1830@manta.NOSC.MIL> Date: 7 Mar 91 18:01:37 GMT Organization: Naval Ocean Systems Center, San Diego Lines: 18 This question concerns the use of the "h" modifier in a printf conversion specification. According to ANSI C, %hi, %hd, etc. indicate that the corresponding argument is to be printed as a short integer. However, since all but the first printf argument are prototyped as being variable arguments, the usual default argument type conversions must occur. Therefore, any argument of type short will be converted to int before being passed. If ints and shorts are the same size, no problem. If ints are larger than shorts, i.e., 32 bit ints and 16 bit shorts, still no problem since printf can use either all 32 bits or only the original 16 and the value will be the same. As far as print format is concerned, doesn't a short get printed in the same format as an int? If this is the case, I fail to see any reason for the existance of "h" since some bizzare form of "lint" would be the only thing that could detect a type mismatch. (I know there must be something I am missing on this.) Ray Mitchell