What is the practical use of the formats \"%*\"
in scanf(). If this format exists, there has to be some purpose behind it. The following program gives weird out
The star is a flag character, which says to ignore the text read by the specification. To qoute from the glibc documentation:
An optional flag character `*', which says to ignore the text read for this specification. When scanf finds a conversion specification that uses this flag, it reads input as directed by the rest of the conversion specification, but it discards this input, does not use a pointer argument, and does not increment the count of successful assignments.
It is useful in situations when the specification string contains more than one element, eg.:
scanf("%d %*s %d", &i, &j)
for the "12 test 34"
- where i & j are integers and you wish to ignore the rest.