Scanf format: %f %d %d %[abcd] %*1d %s%n : scanf format « printf scanf « C Tutorial

Home
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
C Tutorial » printf scanf » scanf format 




#include <stdio.h>
#include <wchar.h>

const size_t SIZE = 20;

int main(void)
{
  int value_count = 0;
  float fp1 = 0.0;
  int i = 0;
  int j = 0;
  char word1[SIZE" ";
  char word2[SIZE" ";
  int byte_count = 0;

  value_count = scanf("%f   %d   %d  %[abcd] %*1d   %s%n",
                      &fp1, &i , &j, word1,  word2, &byte_count);

  printf("\nCount of bytes read = %d\n", byte_count);
  printf("\nCount of values read = %d\n", value_count);
  printf("\nfp1 = %f   i = %d   j = %d", fp1, i, j);
  printf("\nword1 = %s   word2 = %s\n", word1, word2);

  return 0;
}
3
     3
     3
     3
     
     Count of bytes read = 0
     
     Count of values read = 3
     
     fp1 = 3.000000   i = 3   j = 3
     word1 =     word2 =














4.32.scanf format
4.32.1.scanf format
4.32.2.Scanf format: %f %d %d %[abcd] %*1d %s%n
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.