Answers for "snprintf with malloc"

C
0

snprintf with malloc

size_t required_size = snprintf(NULL, 0, "%s: %s (%d)", msg, strerror(errno), errno) + 1;
char  *buffer = malloc(needed);
sprintf(buffer, "%s: %s (%d)", msg, strerror(errno), errno);
Posted by: Guest on January-11-2022

Code answers related to "C"

Browse Popular Code Answers by Language