2017-10-21 23:40:19 +00:00
|
|
|
/* Conformance Test 17.8.0.16: Verification of sscanf, % and [ format codes */
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2022-10-17 22:50:42 +00:00
|
|
|
#include <string.h>
|
2017-10-21 23:40:19 +00:00
|
|
|
|
2022-10-17 22:50:42 +00:00
|
|
|
int main (void)
|
2017-10-21 23:40:19 +00:00
|
|
|
{
|
|
|
|
char sstr [] = "% these are the ^only[ characters"
|
|
|
|
"*aaabbb a fine mess, you see! ddddfffffffff";
|
|
|
|
int i;
|
|
|
|
char string [2] [50] = { {"hey, hey!"}, {"you, you"} };
|
|
|
|
|
|
|
|
|
2022-10-17 22:50:42 +00:00
|
|
|
i = sscanf (&sstr[0], "%%"); /* no assignment made */
|
2017-10-21 23:40:19 +00:00
|
|
|
if (i != 0)
|
|
|
|
goto Fail;
|
|
|
|
|
|
|
|
|
|
|
|
/* Create set of characters which can appear in the output string. */
|
|
|
|
|
2022-10-17 22:50:42 +00:00
|
|
|
i = sscanf (&sstr [1], "%45[thes aronlyc^[] %*[*ab]", string [0]);
|
2017-10-21 23:40:19 +00:00
|
|
|
if (i != 1)
|
|
|
|
goto Fail;
|
2022-10-17 22:50:42 +00:00
|
|
|
if (strcmp (string [0], " these are the ^only[ characters"))
|
2017-10-21 23:40:19 +00:00
|
|
|
goto Fail;
|
|
|
|
|
|
|
|
|
|
|
|
/* Create set of characters which cannot appear in the output string. */
|
|
|
|
|
2022-10-17 22:50:42 +00:00
|
|
|
i = sscanf (&sstr [42], "%[^d] %10[df]", string [0], string [1]);
|
2017-10-21 23:40:19 +00:00
|
|
|
if (i != 2)
|
|
|
|
goto Fail;
|
2022-10-17 22:50:42 +00:00
|
|
|
if (strcmp (string [0], " a fine mess, you see! "))
|
2017-10-21 23:40:19 +00:00
|
|
|
goto Fail;
|
2022-10-17 22:50:42 +00:00
|
|
|
if (strcmp (string [1], "ddddffffff"))
|
2017-10-21 23:40:19 +00:00
|
|
|
goto Fail;
|
|
|
|
|
|
|
|
printf ("Passed Conformance Test 17.8.0.16\n");
|
2022-10-17 22:50:42 +00:00
|
|
|
return 0;
|
2017-10-21 23:40:19 +00:00
|
|
|
|
|
|
|
Fail:
|
|
|
|
printf ("Failed Conformance Test 17.8.0.16\n");
|
2022-10-17 22:50:42 +00:00
|
|
|
return 0;
|
2017-10-21 23:40:19 +00:00
|
|
|
}
|