Back to index

glibc  2.9
scanf4.c
Go to the documentation of this file.
00001 #include <stdio.h>
00002 #include <stdlib.h>
00003 
00004 int
00005 main(int arc, char *argv[])
00006 {
00007   int res;
00008   unsigned int val;
00009 
00010   FILE *fp = fopen ("/dev/null", "r");
00011 
00012   val = 0;
00013   res = fscanf(fp, "%n", &val);
00014 
00015   printf("Result of fscanf %%n = %d\n", res);
00016   printf("Scanned format = %d\n", val);
00017 
00018   res = fscanf(fp, "");
00019   printf("Result of fscanf \"\" = %d\n", res);
00020   if (res != 0)
00021     abort ();
00022 
00023   res = fscanf(fp, "BLURB");
00024   printf("Result of fscanf \"BLURB\" = %d\n", res);
00025   if (res >= 0)
00026     abort ();
00027 
00028   fclose (fp);
00029 
00030   return 0;
00031   return 0;
00032 }