scanf引用第二个值跳转后第三个哪来的

#include"stdio.h"
int main()
{int a,b,c,d;
scanf("%2d%*3d%2d",&a,&b,&c);
printf("%d,%d,%d",a,b,c);}
输入:123456789
输出:12 67 127

%*3d表示忽略域宽为3个字符的整型,因此你输入的字符串中345是被忽略掉了,再接下来%2d读入67是赋给b的,c没有被赋值,其值是未初始化的随机值。

FROM https://en.cppreference.com/w/c/io/fscanf

conversion specifications. Each conversion specification has the following format:

  • introductory % character
  • (optional) assignment-suppressing character *. If this option is present, the function does not assign the result of the conversion to any receiving argument.
  • (optional) integer number (greater than zero) that specifies maximum field width, that is, the maximum number of characters that the function is allowed to consume when doing the conversion specified by the current conversion specification. Note that %s and %[ may lead to buffer overflow if the width is not provided.
  • (optional) length modifier that specifies the size of the receiving argument, that is, the actual destination type. This affects the conversion accuracy and overflow rules. The default destination type is different for each conversion type (see table below).
  • conversion format specifier