
...
Code Block | ||
---|---|---|
| ||
void complain(const char *msg) {
errno_t err;
static const char prefix[] = "Error: ";
static const char suffix[] = "\n";
char buf[BUFSIZ];
static_assert(sizeof(buf) > sizeof(prefix), "Buffer for complain() is too small");
strcpy(buf, prefix);
if ((err = strcat_s(buf, sizeof(buf), msg)) != 0) {
/* handle error */
}
if ((err = strcat_s(buf, sizeof(buf), suffix)) != 0) {
/* handle error */
}
fputs(buf, stderr);
}
|
...