Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

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);
   
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #snprintf #malloc
ADD COMMENT
Topic
Name
3+5 =