scanf() skip variable

ross picture ross · Sep 30, 2011 · Viewed 32.2k times · Source

In C, using scanf() with the parameters, scanf("%d %*d", &a, &b) acts differently. It enters value for just one variable not two!

Please explain this!

scanf("%d %*d", &a, &b);

Answer

jpalecek picture jpalecek · Sep 30, 2011

The * basically means the specifier is ignored (integer is read, but not assigned).

Quotation from man scanf:

 *        Suppresses assignment.  The conversion that follows occurs as
          usual, but no pointer is used; the result of the conversion is
          simply discarded.