出于某种原因,我无法写入从scanf_s我在Visual Studio 2013中使用的ch字符类型我尝试了间距“%c”两种方式“%c”,并尝试scanf和scanf_s。我搞不清楚了。字符类型不接受输入
// Alphabetic Pyramid Program - The Egyptians must have used C!
#include <stdio.h>
int main(void)
{
char ch;
printf("Enter the letter that will be the foundations of your Aphabetic Pyramid:\n"); // User is promted to enter a letter
scanf_s(" %c", &ch); // User inputs Foundational_letter
printf("The code for %c is %d!\n", ch, ch);
getchar();
getchar();
return 0;
}
欢迎来到Stack Overflow。请花些时间阅读[The Tour](http://stackoverflow.com/tour),并参阅[帮助中心](http://stackoverflow.com/help/asking)中的资料,了解您可以在这里问。 –
请记住:C和C++不是同一种语言。只标记一个。另外,对于'scanf_s',我相信你需要提供缓冲区的大小:'scanf_s(“%c”,&ch,1);' –
“我无法从scan_f写入ch char类型。请更具体一些。有错误吗?如果行为不正确,请提供输入,预期结果和实际结果。 – kaylum