tsnprintf.c 584 B

1234567891011121314151617181920212223242526
  1. /*
  2. * If your system does not provide snprintf(), this program will compile
  3. * but will have an undefined error from the linker.
  4. *
  5. * If you are using the lib/snprintf.c function that is supplied for
  6. * systems without snprintf(), you should get an error output from our
  7. * library function.
  8. *
  9. * If your system provides the function, and it works, there should be
  10. * no output.
  11. */
  12. #include "unp.h"
  13. int
  14. main(int argc, char **argv)
  15. {
  16. int n;
  17. char buf[1024];
  18. n = snprintf(buf, 4, "%d", 9999);
  19. if (n > 3)
  20. printf("error: snprintf overflowed buffer, n = %d\n", n);
  21. exit(0);
  22. }