#include /* C example */ #include #define N 100 /* number of characters in string */ int main(int argc, char **argv) { const char word[] = "size"; const int i = 38; const char c = 'L'; char a[N]; /* uninitialized variable */ if (snprintf(a, N, "%s %d%c", word, i, c) < 0) { fprintf(stderr, "%s: snprintf failed\n", argv[0]); return EXIT_FAILURE; } printf("The string contains \"%s\".\n", a); return EXIT_SUCCESS; }