Scroll Down to See All
abortabsacosasctimeasctime_rasinassertatanatan2atexitatofatoiatolbsearchbtowccalloccatclosecatgetscatopenceilclearerrclockcoscoshctimectime_rdifftimediverferfcexitexpfabsfclosefdopenfeofferrorfflushfgetcfgetposfgetsfgetwcfgetwsfopenfprintffputcfputwsfreadfreefreopenfrexpfscanffseekfsetposftellfwidefwprintffwritefwscanfgetcgetchargetenvgetwcgetwchargmtimegmtime_rhypotisalnumisalphaisasciiisblankiscntrlisdigitisgraphislowerisprintispunctisspaceisupperiswalnumiswalphaiswblankiswcntrliswctypeiswdigitiswgraphiswloweriswprintiswpunctiswspaceiswupperiswxdigitisxdigitj0j1jnlabsldexpldivlocaleconvlocaltimelocaltime_rloglog10longjmpmallocmblenmbrlenmbrtowcmbsinitmbsrtowcsmbstowcsmbtowcmemchrmemcmpmemcpymemmovememsetmktimemodfnextafternextafterlnexttowardnexttowardlnl_langinfoperrorpowprintfputcputcharputenvputsputwcputwcharqsortquantexpd32quantexpd64quantexpd128quantized32quantized64quantized128samequantumd32raiserandrand_rreallocregcompregerrorregexecregfreeremoverenamerewindsetbufsetjmpsetlocalesetvbufsignalsinsinhsnprintfsprintfsqrtsrandsscanfstrcasecmpstrcatstrchrstrcmpstrcollstrcpystrcspnstrerrorstrfmonstrftimestrlenstrncasecmpstrncatstrncmpstrncpystrpbrkstrptimestrrchrstrspnstrstrstrtodstrtod32strtod64strtod128strtofstrtokstrtok_rstrtolstrtoldstrtoulstrxfrmswprintfswscanfsystemtantanhtimetime64tmpfiletmpnamtoasciitolowertouppertowctranstowlowertowupperungetcungetwcva_argva_copyva_endva_startvfprintfvfscanfvfwprintfvfwscanfvprintfvscanfvsprintfvsnprintfvsscanfvswprintfvswscanfvwprintfvwscanfwcrtombwcscatwcschrwcscmpwcscollwcscpywcscpywcsftimewcslenwcsncatwcsncmpwcsncpywcspbrkwcsptimewcsrchrwcsrtombswcsspnwcsstrwcstodwcstod32wcstod64wcstod128wcstofwcstokwcstolwcstoldwcstombswcstoulwcsxfrmwctobwctombwctranswctypewcwidthwmemchrwmemcmpwmemcpywmemmovewmemsetwprintfwscanfy0y1yn



Function Details : scanf

intscanf(const char * format,... args) ;

Return Type : int

Integer type (typically 4 bytes, -2,147,483,648 to 2,147,483,647)
Read about return values of scanf function .

1st Parameter Type : const char *

Pointer to read-only string

1st Parameter

A null-terminated format string specifying how to interpret the input, containing format specifiers like `%d`, `%s`, or `%f`.

2nd Parameter Type : ...

Represents a variable number of arguments in a function. Used in functions like `printf` or `fprintf` to accept additional parameters beyond those explicitly declared.

2nd Parameter

A variable number of pointers to variables where the parsed input values will be stored.

Read more about parameters of scanf in parameters section
The scanffunction in C language Reads formatted input from the standard input stream.
The scanf function reads input from the standard input stream stdin, interprets it according to the format string, and stores the results in the locations given by the additional arguments. The format string consists of conversion specifications and ordinary characters.
The scanffunction takes 2 parameters:
  • const char * `format`: A null-terminated format string specifying how to interpret the input, containing format specifiers like `%d`, `%s`, or `%f`.
  • ... `args`: A variable number of pointers to variables where the parsed input values will be stored.
Reads formatted input from the standard input stream (`stdin`) based on the `format` string. The function stores the parsed input into the variables pointed to by `args`. Returns the number of successfully matched and assigned input items, or `EOF` if an input failure occurs before any items are matched.
The scanf function return value :
  • Returns the number of input items successfully matched and assigned
  • Returns EOF if input failure occurs before the first conversion

Output

This example demonstrates basic usage of scanf to read an integer and a string from standard input.