The square brackets are a special form of the 's' specifier. They are similar to square brackets used in a regex expression. They define a class of characters for scanf to match. For example, %[abc] asks scanf to capture the character if it is an 'a' OR a 'b' OR a 'c', and stash it in our specified variable. The '^' character has the effect of inverting the request. For example, %[^abc] asks scanf to capture the character if it is NOT an 'a' or 'b' or 'c'.

This is documented in your material regarding 'scanf'. You might want to read that.