Mega Code Archive

 
Categories / C Tutorial / Stdio h
 

Scanf

Item Value Header filestdio.h Declarationint scanf(const char *format, ...); Functionread input. The control string pointed to by format consists of three classifications of characters: Format specifiers White-space characters Non-white-space characters The scanf() Format Specifiers CodeMeaning %aRead a floating-point value (C99 only) %ASame as %a (C99 only) %cRead a single character %dRead a decimal integer %iRead an integer in either decimal, octal, or hexadecimal format %eRead a floating-point number %ESame as %e %fRead a floating-point number %FSame as %f (C99 only) %gRead a floating-point number %GSame as %g %oRead an octal number %sRead a string %xRead a hexadecimal number %XSame as %x %pRead a pointer %nReceive an integer value equal to the number of characters read so far %uRead an unsigned decimal integer %[ ]Scan for a set of characters %%Read a percent sign #include <stdio.h>   int main(void)   {     char str[80], str2[80];     int i;     /* read a string and an integer */     scanf("%s%d", str, &i);     return 0;   }