#include #include char *longstr = "01234567890abcdefghijklmnopqrstuvwxyz" "01234567890abcdefghijklmnopqrstuvwxyz" "01234567890abcdefghijklmnopqrstuvwxyz" "01234567890abcdefghijklmnopqrstuvwxyz" "01234567890abcdefghijklmnopqrstuvwxyz" "01234567890abcdefghijklmnopqrstuvwxyz"; void with_check(char *src) { char buf[20]; int len; puts("with_check"); len = strlcpy(buf, src, sizeof(buf)); if (len > sizeof(buf) - 1) printf("with_check: buf is too short to copy src(%s).\n", src); printf("with_check: buf(%s)\n", buf); } void without_check(char *src) { char buf[20]; puts("without_check"); strcpy(buf, src); printf("without_check: buf(%s)\n", buf); } int main(void) { with_check(longstr); without_check(longstr); return 0; }