scanf : scanf « stdio.h « C Tutorial

C Tutorial
1. Language
2. Data Type
3. String
4. printf scanf
5. Operator
6. Statement
7. Array
8. Function
9. Structure
10. Pointer
11. Memory
12. Preprocessor
13. File
14. Data Structure
15. Search Sort
16. Wide Character String
17. assert.h
18. ctype.h
19. math.h
20. setjmp.h
21. signal.h
22. stdio.h
23. stdlib.h
24. string.h
25. time.h
26. wctype.h
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
C Tutorial » stdio.h » scanf 
22. 31. 1. scanf
ItemValue
Header filestdio.h
Declarationint scanf(const char *format, ...);
Functionread input.


The control string pointed to by format consists of three classifications of characters:

  1. Format specifiers
  2. White-space characters
  3. 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;
  }
22. 31. scanf
22. 31. 1. scanf
w_ww.___j_av__a___2_s__.___c_o__m_ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.