...
Code Block | ||||
---|---|---|---|---|
| ||||
void complain(const char *msg) { errno_t err; static const char prefix[] = "Error: "; static const char suffix[] = "\n"; char buf[BUFSIZ]; err = strcpy_s(buf, sizeof(buf), prefix); if (err != 0) { /* handleHandle error */ } err = strcat_s(buf, sizeof(buf), msg); if (err != 0) { /* handleHandle error */ } err = strcat_s(buf, sizeof(buf), suffix); if (err != 0) { /* handleHandle error */ } fputs(buf, stderr); } |
...
Code Block | ||||
---|---|---|---|---|
| ||||
void complain(const char *msg) { errno_t err; static const char prefix[] = "Error: "; static const char suffix[] = "\n"; char buf[BUFSIZ]; /* Ensure that more than one character * is available for msg. */ static_assert(sizeof(buf) > sizeof(prefix) + sizeof(suffix), "Buffer for complain() is too small"); strcpy(buf, prefix); err = strcat_s(buf, sizeof(buf), msg); if (err != 0) { /* handleHandle error */ } err = strcat_s(buf, sizeof(buf), suffix); if (err != 0) { /* handleHandle error */ } fputs(buf, stderr); } |
...
ISO/IEC TR 24731-1:2007 | |
ISO/IEC TR 24731-2:2010 | |
ISO/IEC TR 24772:2013 | Use of Libraries [TRJ] |
Bibliography
[Seacord | 2005a2005b] | Chapter 2, "Strings"Managed String Library for C, C/C++" |
[Seacord 2005b2013] | Chapter 2, "Strings" |
...