#include #include typedef char* png_charp; typedef const char* png_const_charp; /* Utility to safely appends strings to a buffer. This never errors out so * error checking is not required in the caller. */ size_t png_safecat(png_charp buffer, size_t bufsize, size_t pos, png_const_charp string) { if (buffer != NULL && pos < bufsize) { if (string != NULL) { while (*string != '\0' && pos < bufsize-1) { buffer[pos++] = *string++; } } buffer[pos] = '\0'; } return pos; } int main() { size_t pos = 0; char number_buf[5]; /* enough for a four-digit year */ /* FLTK Issue #296 */ png_safecat(number_buf, sizeof(number_buf), pos, "ABC"); printf("RESULT: '%s'\n", number_buf); return 0; }