fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4.  
  5. int main()
  6. {
  7. char d[8];
  8. char d_format[32];
  9.  
  10. if (snprintf(d_format, sizeof(d_format), "%%%lus", sizeof(d) - 1) > 0)
  11. {
  12. printf("d_format=[%s]\n", d_format);
  13. if (1 == scanf(d_format, d))
  14. {
  15. printf("%s\n", d);
  16. }
  17. }
  18. return 0;
  19. }
  20.  
Success #stdin #stdout 0s 2296KB
stdin
1234567890
stdout
d_format=[%7s]
1234567