2017-10-21 23:40:19 +00:00
|
|
|
/* Conformance Test 17.8.0.14: Verification of sscanf, s format code */
|
|
|
|
|
|
|
|
#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 [] = " oneLongWord ten-chars!andMore";
|
|
|
|
int i, j;
|
|
|
|
char string [50] = "hey, hey!";
|
|
|
|
|
|
|
|
|
2022-10-17 22:50:42 +00:00
|
|
|
i = sscanf (&sstr[0], "%*s"); /* no assignment made */
|
2017-10-21 23:40:19 +00:00
|
|
|
if (i != 0)
|
|
|
|
goto Fail;
|
|
|
|
if (strcmp (string, "hey, hey!"))
|
|
|
|
goto Fail;
|
|
|
|
|
2022-10-17 22:50:42 +00:00
|
|
|
i = sscanf (&sstr [14], "%10s", string); /* test assignment to string*/
|
|
|
|
if (i != 1)
|
2017-10-21 23:40:19 +00:00
|
|
|
goto Fail;
|
|
|
|
if (strcmp (string, "ten-chars!"))
|
|
|
|
goto Fail;
|
|
|
|
|
|
|
|
printf ("Passed Conformance Test 17.8.0.14\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.14\n");
|
2022-10-17 22:50:42 +00:00
|
|
|
return 0;
|
2017-10-21 23:40:19 +00:00
|
|
|
}
|