February 2020
Beginner to intermediate
616 pages
15h 16m
English
In this recipe, we will use the snprintf function. The snprintf function will assign the formatted text to the name member but will limit the size of the string assigned to it. The difference between the sprintf and snprintf functions is that sprintf simply assigns the complete formatted text to the destination string no matter what its capacity, whereas snprintf allows us to specify the maximum length of the text that can be assigned to the destination string. Therefore, a buffer overflow will not occur as only the specified size of the text is assigned to the destination string.
Read now
Unlock full access