[previous] 0203 [next] [U] Value of character prior to '-' in '[]' is greater than following character.
Explicitly undefined REFERENCE - ISO:C90-7.9.6.2 The fscanf Function

The character range defined in this '%[]' conversion specifier is probably incorrect.

The brackets contain a scanset - a set of characters. Characters from the input stream are written to the receiving character buffer until a character is encountered which is not in the scanset. A scanset may be defined as a list of characters (e.g. "abcdef") or, as in this case, as a range ("a-f"). In the range specified here, the character on the right side of the '-' is less than the character on the left.

For example:


/*PRQA S 336,602,1302,1307,2017,3122,3132,3200,3209,3335,3408,3602,3625 ++*/

#include <stdio.h>

extern void foo(void)
{
    char hb[20];

    scanf("%[ABCDEF]", hb);     /*                       */

    scanf("%[A-F]", hb);        /* Message 0202          */

    scanf("%[F-A]", hb);        /* Message 0203 and 0202 */

}

See also:

QA·C Source Code Analyser 8.1.2
© 2013 Programming Research.
www.programmingresearch.com
Personality Groups | Glossary | Message Index Contents