blob: ad1cebc8c2661cdf2b5d65a7803e7c72b91258e9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
|
#include <stdio.h>
int main() {
int size = snprintf(NULL, 0, "%s %d %.2f\n", "me and myself", 25, 1.345);
char buf[size];
snprintf(buf, size, "%s %d %.2f\n", "me and myself", 25, 1.345);
printf("%d : %s\n", size, buf);
char *buff = NULL;
asprintf(&buff, "%d waka %d\n", 21, 95);
puts(buff);
return 0;
}
|