diff options
Diffstat (limited to 'test/stdio')
-rw-r--r-- | test/stdio/scanf_m.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/stdio/scanf_m.c b/test/stdio/scanf_m.c new file mode 100644 index 000000000..0ce78b6e4 --- /dev/null +++ b/test/stdio/scanf_m.c @@ -0,0 +1,24 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +int main(void) +{ + const char *buf = "hello world"; + char *ps = NULL, *pc = NULL; + char s[6], c; + + /* Check that %[...]/%c work. */ + sscanf(buf, "%[a-z] %c", s, &c); + /* Check that %m[...]/%mc work. */ + sscanf(buf, "%m[a-z] %mc", &ps, &pc); + + if (strcmp(ps, "hello") != 0 || *pc != 'w' || + strcmp(s, "hello") != 0 || c != 'w') + return 1; + + free(ps); + free(pc); + + return 0; +} |