aboutsummaryrefslogtreecommitdiff
path: root/stdio-common/scanf4.c
blob: 177b2ec22f0a024a979bd30a0a94fd2ddf0c6f54 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <stdio.h>

int
main(int arc, char *argv[])
{
  int res;
  unsigned int val;

  FILE *fp = fopen ("/dev/null", "r");

  val = 0;
  res = fscanf(fp, "%n", &val);

  printf("Result of fscanf %%n = %d\n", res);
  printf("Scanned format = %d\n", val);

  res = fscanf(fp, "");
  printf("Result of fscanf \"\" = %d\n", res);
  if (res != 0)
    abort ();

  res = fscanf(fp, "BLURB");
  printf("Result of fscanf \"BLURB\" = %d\n", res);
  if (res >= 0)
    abort ();

  fclose (fp);

  return 0;
  return 0;
}