Back to index

glibc  2.9
Functions
scanf3.c File Reference
#include <stdio.h>
#include <stdlib.h>

Go to the source code of this file.

Functions

int main (int arc, char *argv[])

Function Documentation

int main ( int  arc,
char *  argv[] 
)

Definition at line 5 of file scanf3.c.

{
  int n, res;
  unsigned int val;
  char s[] = "111";

  val = n = -1;
  res = sscanf(s, "%u %n", &val, &n);
  printf("Result of sscanf = %d\n", res);
  printf("Scanned format %%u = %u\n", val);
  printf("Possibly scanned format %%n = %d\n", n);
  if (n != 3 || val != 111 || res != 1)
    abort ();

  val = n = -1;
  res = sscanf(s, "%u%n", &val, &n);
  printf("Result of sscanf = %d\n", res);
  printf("Scanned format %%u = %u\n", val);
  printf("Possibly scanned format %%n = %d\n", n);
  if (n != 3 || val != 111 || res != 1)
    abort ();

  return 0;
}

Here is the call graph for this function: