asprintf function

in security •  8 years ago 

□ allocated string printf
□ It is function of GNU extensions(No C or POSIX)
□ int asprintf(char **strp, const char *fmt, ...)
□ It prints the contents of fmt to the strp. As much as the fmt+null's size, a memory is allocated to the strp. Later additionally, memory release is needed.
□ When successful, it returns the number of characters printed. When an error occurs, It returns -1.

□ Example : This stores the string "This sis infosec" in the buffer
char *buffer;
asprintf(&buffer, "This is %s", "INFOSEC");

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!