aboutsummaryrefslogtreecommitdiff
path: root/stdio-common/scanf4.c
blob: b624b69d98bb731237743b4308b47301b1588496 (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
#include <stdio.h>

int main(int arc, char *argv)
{
  int n, 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;
}