Which of the following conditions is safe for buffer overflows?
char buf[10] = {0}; scanf("%10s", buf);
or
char buf[10] = {0}; scanf("%9s", buf);
From what I read, I'm going to the second one (sizeof minus one), but the question is pretty subtle, and I saw code suggesting either. Any volunteer to quote the standard?
jimis source share