14 printf("hullo this is a %s !", "test");
15 (void) scanf("hullo, welcome to %d", &i
); /* defines i */
17 printf("even %d %c harder", i
, c
); /* 1. Variable c used before definition */
19 printf("even %d %c harder", li
, uc
); /* 2. printf format arg 1 (%d) expects int gets long int: li */
20 printf("even %ld %d %hd %hd %d harder", i
, li
, i
, silly
, silly
); /* 3, 4. [5, 6.]
21 * arg1 (expects long),
24 * (okay if +relaxquals) arg5 (expects int) */
26 (void) scanf("%*d okay"); /* [NO! 5. Statement has no effect] */
27 printf("%s %s", s
, s
); /* 5. Variable s used before definition */
29 printf("a real %+14.3i", c
, i
); /* 6, 7. printf format arg 1 (%i) expects int gets char: c, extra arg */
30 fprintf(stdout
, "a real %+14.33i", c
, i
); /* 8, 9. fprintf format arg 1 (%i) expects int gets char: c, extra */
31 printf("%% %d %f %f", c
, i
); /* 10, 11, 12. printf format arg 1, arg2, missing arg 3 */
33 (void) scanf("hullo, welcome to %d", &i
);
34 (void) scanf("hullo, welcome to %d", i
); /* 13. scanf format arg 1 (%d) expects int * gets int: i */
37 (void) fscanf(stdin
, "hullo, welcome to %d %c %s", i
, c
, &s
); /* 14, 15, 16. arg1, arg2, arg3 */
39 /* 3 modification errors */
40 (void) fscanf(stdin
, "hullo, welcome to %23d %c %s", &gi
, &gc
, gs
); /* 17, 18, 19. modifies g1, gc, gs */
41 /* 1 modification error */
42 (void) fscanf(stdin
, "hullo, welcome to %*23d %*c %s", gs
); /* 20. modifies gs */