Why use asprintf() instead of sprintf()?
If you use sprintf() or vsprintf(), you need to allocate a buffer first, and you need to be sure that the buffer is large enough to contain what sprintf writes. Otherwise sprintf() will happily overwrite whatever memory lies beyond the end of the buffer. char* x = malloc(5 * sizeof(char)); // writes “123456” +null but … Read more