@WhozCraig are the well-identified flaws of this tip. It comes without reasonable or detailed. It does not further refer to "%s" because "%s" consumes leading white space with or without leading space.
The leading white space, be it ' ' , '\t' , '\n' , etc., all do the same thing: direct scanf() to consume and not store the additional leading white space char . This is useful because the typical use of the previous scanf() does not consume the user '\n' from Enter
scanf("%d", &some_int); scanf("%c", &some_char);
All scanf() input qualifiers ignore leading spaces, except for 3: "%c" , "%n" , "%[]" .
Just a directive brings an advantage with a leading space, as in the following. The previous remaining space is consumed before '$' .
int Money; scanf(" $%d", &Money);
Often, although not always leading space up to "%c" is useful, as when reading a single char user input.
char ch; scanf(" %c", &ch);
The worst part about the tip is that 1) when using "%s" providing the width parameter is important for reliable code, and 2) you need to check the return value.
char buf[30]; int cnt = scanf("%29s", buf); if (cnt != 1) Handle_NoInput_or_EOF_IOError();
Finally, it is recommended that you use fgets() over scanf() , as you can, which is usually the case.