gpt4 book ai didi

c - 为什么 scanf ("%c", &ch ) 不从控制台读取字符,而 scanf ("%c", &ch ) 会

转载 作者:行者123 更新时间:2023-11-30 19:31:36 27 4
gpt4 key购买 nike

scanf("%c", &ch ) scanf(" %c", &ch ) 时不要从控制台读取字符是的,代码片段在下面给出

printf("If the value of speed of sound is known enter Y else enter N");
scanf(" %c", &ch );

最佳答案

scanf(" %c", &ch );

%c 之前的这个空格可能是用来处理缓冲的换行符的。请参阅[ this ]回答。

关于c - 为什么 scanf ("%c", &ch ) 不从控制台读取字符,而 scanf ("%c", &ch ) 会,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48299112/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com