Conversion Specifications for function scanf() - C Reference

C examples for Reference:Language Reference

Introduction

C.S. Input Data and Supported Types
%ccharacter. The default width of input field is 1. White space characters are also treated as data by this conversion specification. Types: char.
%ddecimal integer. Types: short int, int, signed int, signed short int, unsigned short int.
%hd decimal integer. Types: short int, signed short int, unsigned short int.
%ld decimal integer. Types: long int, signed long int.
%iinteger. The integer may be octal (leading 0) or hexadecimal (leading 0x or 0X). Types: short int, int, signed int, signed short int, unsigned short int.
%li integer. The integer may be octal (leading 0) or hexadecimal (leading 0x or 0X). Types: long int, signed long int.
%ooctal integer, with or without leading zero. Types: unsigned short int, unsigned int.
%lo octal integer, with or without leading zero. Types: unsigned long int.
%uunsigned decimal integer. Types: unsigned int.
%lu decimal integer. Types: unsigned long int.
%xhexadecimal integer, with or without leading 0x or 0X. unsigned short int, unsigned int.
%lx hexadecimal integer, with or without leading 0x or 0X. unsigned long int.
%sstring of non-white space characters which is not delimited by double quotes.
%ffloating-point number. Accepts number in standard form. Types: float.
%efloating-point number. Accepts number in exponent form. Types: float.
%gfloating-point number. Accepts number in exponent form. Types: float.
%lf floating-point number. Accepts number in standard form. Types: double.
%le floating-point number. Accepts number in exponent form. Types: double.
%lg floating-point number. Accepts number in exponent form. Types: double.
%Lf floating-point number. Accepts number in standard form. Types: long double.
%Le floating-point number. Accepts number in exponent form. Types: long double.
%Lg floating-point number. Accepts number in exponent form. Types: long double.
%ppointer value as printed by printf("%p");
%nwrites into the argument the number of characters read so far by this call.
%[...] matches the longest non-empty string of input characters from the set between square brackets.
%[^...] matches the longest non-empty string of input characters not from the set between square brackets.

Related Tutorials