The %n Specifier
The %n specifier instructs scanf() to assign the number of characters read at the point at which the %n was encountered to the variable pointed to by the corresponding argument.



--------------------------------------------------------------------------------


Using a Scanset
The ANSI standard added the new scanset feature. A scanset defines a set of characters which may be read and assigned to the corresponding character array.

A scanset is defined by placing the characters inside square brackets prefixed with a %, as in the following example:

     %["XYZ"]
scanf() will then continue to read characters and continue to put them into the array until it encounters a character not in the scanset. For example, given the following code:

     scanf(%d%[abcdefg]%s", &i, str, str2);
     printf(%d %s %s, i, str, str2);
entering 123abcdtye followed by ENTER would display:

     123 abcd tye
because the t is not part of the scanset, causing it and the remaining characters to be put into str2.

If the first character in the set is a ^, scanf() will accept any character not defined by the scanset. A range may be specified using a hyphen. Scansets are case sensitive.

