Re: how to print a short and long integer?



a wrote:
short s;
long l;
s= -2;
l= -3;
printf("% _  %_",s, l);
What characters should be filled out in the formatted string for output?
Thanx

#include <stdio.h> int main(void) { short s = -2; long l = -3; printf("The standard way using \"%%hd %%ld\": %hd %ld\n", s, l); printf(" (but \"%%d %%ld\" should work as well: %d %ld\n", s, l); return 0; }


The standard way using "%hd %ld": -2 -3 (but "%d %ld" should work as well: -2 -3 .



Relevant Pages

  • Re: printf query
    ... int main ... On success, printf returns the number of characters printed, not the ... Note that the order of evaluation is unambiguous; ...
    (comp.lang.c)
  • Re: program
    ... Omitting a prototype for printf() yields undefined behavior, ... costs 15 more characters, ... int main{char p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.\ ...
    (comp.lang.c)
  • Re: Seg fault + string manipulation
    ... int main (void) ... I think the printf version is stylistically ... only of printing characters and the control characters ...
    (comp.lang.c)
  • Re: how to print a short and long integer?
    ... Lew Pitcher a écrit: ... long l; s= -2; l= -3; printf("% _ %_",s, l); ... What characters should be filled out in the formatted string for output? ...
    (comp.lang.c)
  • Re: for loop skipping items
    ... > How comes the for loop just printf 3 characters? ... int main ...
    (comp.lang.c)