scanf("%*d",&a) * skips input. To read the inputs, you need to use the extra "%d" in scanf . For example:
int a=1,b=2,c=3; scanf("%d %*d %d",&a,&b,&c); //input is given as: 10 20 30
O / r
a=10 b=30 and c=3; // 20 is skipped
If you use another %d ie: scanf("%d %*d %d %d",&a,&b,&c); //input is given as: 10 20 30 40 scanf("%d %*d %d %d",&a,&b,&c); //input is given as: 10 20 30 40 then a = 10 b = 30 c = 40.
If you use "," in scanf, no value will be accepted after %*d ie; scanf("%d %*d,%d" &a,&b,&c)// 10 20 30 O / P: a = 10 b = 2 c = 3 there will be an output.
Raunak Chowdhury Sep 23 '13 at 15:49 2013-09-23 15:49
source share