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 (void) scanf("hullo, welcome to %hhd", &c
);
40 fprintf(stdin
, "hullo, welcome to %hhu\n", c
); /* 17. */
42 (void) fscanf(stdout
, "hullo, welcome to %hho", &c
); /* 18. */
43 printf("hullo, welcome to %hhi\n", c
);
45 /* 3 modification errors */
46 (void) fscanf(stdin
, "hullo, welcome to %23d %c %s", &gi
, &gc
, gs
); /* 19, 20, 21. modifies g1, gc, gs */
47 /* 1 modification error */
48 (void) fscanf(stdin
, "hullo, welcome to %*23d %*c %s", gs
); /* 22. modifies gs */