scanf format : scanf format « printf scanf « C Tutorial






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

const size_t SIZE = 20;

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

  value_count = scanf("%4f %*d %[abcdefghijklmnopqrstuvwxyz] %*1d %[^o]%n",
                                           &fp1, 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 ", fp1);
  printf("\nword1 = %s   word2 = %s\n", word1, word2);

  return 0;
}
1
     1
     2
     
     Count of bytes read = 0
     
     Count of values read = 1
     
     fp1 = 1.000000
     word1 =     word2 =








4.32.scanf format
4.32.1.scanf format
4.32.2.Scanf format: %f %d %d %[abcd] %*1d %s%n