*variable 在 scanf 中的用法以及我们为什么使用它?

Usage of *variable in scanf and why we use it?

你好,我是初学者,我一直在代码中看到这个,但我不知道它到底是什么意思...... 就像下面的例子

#include<stdio.h>

int main(void)
{
    char c1;
    do
    {
        scanf_s("%c%*c", &c1, 1);
        if ((c1>='a' && c1<='z')||(c1 >= 'A' && c1 <= 'Z'))
        {
            printf("%c  %d", c1, c1);
        }

    } while (c1!=0);
    return 0;
}

像这里一样,它是转换 char 还是存储它的值?? scanf 中的 (%*c) 对我来说是个谜,据我所知,它有点像对内存的引用,但不会启动任何变量,它只是指向内存中存储的值... 我说的对吗???

来自C标准(7.21.6.2 fscanf函数)

3....After the %, the following appear in sequence:

An optional assignment-suppressing character *.

— An optional decimal integer greater than zero that specifies the maximum field width (in characters).

— An optional length modifier that specifies the size of the receiving object.

— A conversion specifier character that specifies the type of conversion to be applied.

and (K.3.5.3.2 fscanf_s函数)

4 The fscanf_s function is equivalent to fscanf except that the c, s, and [ conversion specifiers apply to a pair of arguments (unless assignment suppression is indicated by a *)....

所以在这次通话中

scanf_s("%c%*c", &c1, 1);

格式%*c禁止将读取的字符分配给参数。通常这样的做法是从缓冲区中读取用户按下回车键后出现的换行符。