/* * SPDX-FileCopyrightText: 2018 Bruce Cowan <bruce@bcowan.me.uk> * * SPDX-License-Identifier: GPL-3.0-or-later */ #include <stdio.h> #ifdef __GNUC__ #pragma GCC diagnostic ignored "-Wformat-truncation" #endif int main (void) { char string[8 + 1]; printf ("The following string should be 10 digits long\n"); snprintf (string, sizeof(string), "1234567890"); printf ("%s\n", string); printf ("But it's only 8, which is one fewer than the char array length\n"); return 0; }