string test alignment fix by Mahesh Bodapati
[libc-test.git] / src / regression / scanf-bytes-consumed.c
blobd4e30e42de48e6f27d97513c54d4578336038287
1 // commit: 5efc6af4ebb9d50eb978d0338835544fdfea0396 2011-04-25
2 // scanf misreports bytes consumed when EOF is hit (or null for sscanf)
3 #include <stdio.h>
4 #include "test.h"
6 int main(void)
8 char buf[] = { 'a', 'a', 0 };
9 char dest[3];
10 int read_count;
11 int n;
13 n = sscanf(buf, "%s%n", dest, &read_count);
14 if(n != 1)
15 t_error("sscanf matched 1 input items but returned %d\n", n);
16 if(read_count != 2)
17 t_error("sscanf consumed 2 bytes but reported %d\n", read_count);
18 return t_status;