X-Git-Url: https://git.lttng.org/?p=ust.git;a=blobdiff_plain;f=snprintf%2Fprog.c;fp=snprintf%2Fprog.c;h=157511bad78697e11ed4f8a8c1d0e5d45e2bcd6c;hp=0000000000000000000000000000000000000000;hb=bf0d695d692163edb23b8fbbbd976387dfef232d;hpb=a0c822d0d08ba0f78c85d11871dc733c35db4ee8 diff --git a/snprintf/prog.c b/snprintf/prog.c new file mode 100644 index 0000000..157511b --- /dev/null +++ b/snprintf/prog.c @@ -0,0 +1,18 @@ +#include +#include + +int main() +{ + char buf[100]; + + char *expected; + + expected = "header 9999, hello, 003"; + ust_safe_snprintf(buf, 99, "header %d, %s, %03d", 9999, "hello", 3); + if(strcmp(buf, expected) != 0) { + printf("Error: expected \"%s\" and got \"%s\"\n", expected, buf); + return 1; + } + + return 0; +}