Back to index

glibc  2.9
bug10.c
Go to the documentation of this file.
00001 #include <stdio.h>
00002 
00003 int
00004 main (int arc, char *argv[])
00005 {
00006   int n, res;
00007   unsigned int val;
00008   char s[] = "111";
00009   int result = 0;
00010 
00011   n = 0;
00012   res = sscanf(s, "%u %n", &val, &n);
00013 
00014   printf("Result of sscanf = %d\n", res);
00015   printf("Scanned format %%u = %u\n", val);
00016   printf("Possibly scanned format %%n = %d\n", n);
00017   result |= res != 1 || val != 111 || n != 3;
00018 
00019 
00020   result |= sscanf ("", " %n", &n) == EOF;
00021 
00022   puts (result ? "Test failed" : "All tests passed");
00023 
00024   return result;
00025 }