在C中,使用scanf()参数,scanf("%d %*d", &a, &b)行为不同.只为一个变量而不是两个变量输入值!
请解释一下!
scanf("%d %*d", &a, &b);
Run Code Online (Sandbox Code Playgroud)
jpa*_*cek 24
所述*基本上意味着说明符被忽略(整数被读取,但是未分配).
man scanf的报价:
Run Code Online (Sandbox Code Playgroud)* Suppresses assignment. The conversion that follows occurs as usual, but no pointer is used; the result of the conversion is simply discarded.
Tom*_*icz 14
星号(*)表示将读取格式的值,但不会写入变量.scanf不希望在其参数列表中为该值指定变量指针.你应该写:
scanf("%d %*d",&a);
Run Code Online (Sandbox Code Playgroud)