%*s means in sscanf

Write your question here.

1
2
3
4
5
6
7
8
9
10
11
12
  #include <stdio.h>

int main ()
{
  char sentence []="Rudolph is 12 years old";
  char str [20];
  int i;

  sscanf (sentence,"%s %*s %d",str,&i);
  printf ("%s -> %d\n",str,i);
  
  return 0;


what is the role of "%*s" here?
i know "rudolph" will be print to str
usually if use *s , we have to point how many characters will be copy from buffer(?)
and %d is 12
thanks!!
Last edited on
https://en.cppreference.com/w/cpp/io/c/fscanf

%*s causes a string to be read and discarded.
Topic archived. No new replies allowed.