Stringa formato della funzione scanf

List

Questa pagina fa parte del Manuale Programmazione IEC 61131-3. Vai all indice.

Le funzioni di gestione lettura formattata da stream (Indicate come scanf) permettono di gestire l’iinput da stream di comunicazione e/o da stringa in modo flessibile gestendone la scansione formattata attraverso la definizione di un segnaposto nella stringa di formato. Vedere esempi di utilizzo nella funzione SysVsscanf.

Specifier Meaning
%d An integer in normal decimal (that is, base-10) notation.
%oAn integer in octal (base-8) notation.
%xAn integer in hexadecimal (base-16) notation.
%DAn integer in decimal, or (if it starts with 0) octal, or (if it starts with 0x) hexadecimal notation. Hence, sscanf(“12”, “%D”, i), sscanf(“014”, “%D”, i) and sscanf(“0xC”, “%D”, i) all yield the value 12 in i.
%fA floating-point number.
%cThe character code of a single character.
%sA string. If %s is followed by %d, %s will read any non-numerical characters. If followed by %[], %s will read any characters not present in the set in the %[]. If followed by normal text, %s will match all characters up to, but not including, the first occurrence of that text.
%NsAs above, but a string of exactly N characters
%[chars]A string containing any of the characters in the list characters.
A minus sign can be used to give a range of values, so e. g. %[a-d] means a string consisting of any of the characters a, b and c.
A ^ sign means “not”, so e. g. %[^abc] means any character except a, b and c.
They can be combined, so %[a-cf] means a, b, c, and f.
%%A single percent (%) character.

Se viene posto un asterisco tra il segno % ed l’operatore (Esempio %*d) la funzione esegue la scansione dell’operatore ma non valorizza la variabile di ritorno. Questo può essere utile per saltare dalla stringa alcuni caratteri.

Was this article helpful?