printf("nil pointer (padded):\t\"%10p\"\n", (PTR) NULL);
printf("nil pointer (padded):\t\"%10p\"\n", (void *) NULL);
main (int argc, char *argv[]){  static char shortstr[] = "Hi, Z.";  static char longstr[] = "Good morning, Doctor Chandra.  This is Hal.  \I am ready for my first lesson today.";  fmtchk("%.4x");  fmtchk("%04x");  fmtchk("%4.4x");  fmtchk("%04.4x");  fmtchk("%4.3x");  fmtchk("%04.3x");  fmtst1chk("%.*x");  fmtst1chk("%0*x");  fmtst2chk("%*.*x");  fmtst2chk("%0*.*x");#ifndef	BSD  printf("bad format:\t\"%z\"\n");  printf("nil pointer (padded):\t\"%10p\"\n", (PTR) NULL);#endif  printf("decimal negative:\t\"%d\"\n", -2345);  printf("octal negative:\t\"%o\"\n", -2345);  printf("hex negative:\t\"%x\"\n", -2345);  printf("long decimal number:\t\"%ld\"\n", -123456L);  printf("long octal negative:\t\"%lo\"\n", -2345L);  printf("long unsigned decimal number:\t\"%lu\"\n", -123456L);  printf("zero-padded LDN:\t\"%010ld\"\n", -123456L);  printf("left-adjusted ZLDN:\t\"%-010ld\"\n", -123456);  printf("space-padded LDN:\t\"%10ld\"\n", -123456L);  printf("left-adjusted SLDN:\t\"%-10ld\"\n", -123456L);  printf("zero-padded string:\t\"%010s\"\n", shortstr);  printf("left-adjusted Z string:\t\"%-010s\"\n", shortstr);  printf("space-padded string:\t\"%10s\"\n", shortstr);  printf("left-adjusted S string:\t\"%-10s\"\n", shortstr);  printf("null string:\t\"%s\"\n", (char *)NULL);  printf("limited string:\t\"%.22s\"\n", longstr);  printf("e-style >= 1:\t\"%e\"\n", 12.34);  printf("e-style >= .1:\t\"%e\"\n", 0.1234);  printf("e-style < .1:\t\"%e\"\n", 0.001234);  printf("e-style big:\t\"%.60e\"\n", 1e20);  printf ("e-style == .1:\t\"%e\"\n", 0.1);  printf("f-style >= 1:\t\"%f\"\n", 12.34);  printf("f-style >= .1:\t\"%f\"\n", 0.1234);  printf("f-style < .1:\t\"%f\"\n", 0.001234);  printf("g-style >= 1:\t\"%g\"\n", 12.34);  printf("g-style >= .1:\t\"%g\"\n", 0.1234);  printf("g-style < .1:\t\"%g\"\n", 0.001234);  printf("g-style big:\t\"%.60g\"\n", 1e20);  printf (" %6.5f\n", .099999999860301614);  printf (" %6.5f\n", .1);  printf ("x%5.4fx\n", .5);  printf ("%#03x\n", 1);  {    double d = FLT_MIN;    int niter = 17;    while (niter-- != 0)      printf ("%.17e\n", d / 2);    fflush (stdout);  }  printf ("%15.5e\n", 4.9406564584124654e-324);#define FORMAT "|%12.4f|%12.4e|%12.4g|\n"  printf (FORMAT, 0.0, 0.0, 0.0);  printf (FORMAT, 1.0, 1.0, 1.0);  printf (FORMAT, -1.0, -1.0, -1.0);  printf (FORMAT, 100.0, 100.0, 100.0);  printf (FORMAT, 1000.0, 1000.0, 1000.0);  printf (FORMAT, 10000.0, 10000.0, 10000.0);  printf (FORMAT, 12345.0, 12345.0, 12345.0);  printf (FORMAT, 100000.0, 100000.0, 100000.0);  printf (FORMAT, 123456.0, 123456.0, 123456.0);#undef	FORMAT  {    char buf[20];    printf ("snprintf (\"%%30s\", \"foo\") == %d, \"%.*s\"\n",	    snprintf (buf, sizeof (buf), "%30s", "foo"), sizeof (buf), buf);  }  fp_test ();  printf ("%e should be 1.234568e+06\n", 1234567.8);  printf ("%f should be 1234567.800000\n", 1234567.8);  printf ("%g should be 1.23457e+06\n", 1234567.8);  printf ("%g should be 123.456\n", 123.456);  printf ("%g should be 1e+06\n", 1000000.0);  printf ("%g should be 10\n", 10.0);  printf ("%g should be 0.02\n", 0.02);  {    double x=1.0;    printf("%.17f\n",(1.0/x/10.0+1.0)*x-x);  }  puts ("--- Should be no further output. ---");  rfg1 ();  rfg2 ();  {    char buf[200];    int result;    sprintf(buf,"%*s%*s%*s",-1,"one",-20,"two",-30,"three");    result = strcmp (buf,		     "onetwo                 three                         ");    puts (result != 0 ? "Test failed!" : "Test ok.");    return result != 0;  }}