[英]scanf_s reading characters what am i doing wrong?
{
printf("Please give a random positive number for X: \n");
scanf_s("%i", &X);
char ch = getchar();
char Gender;
if (isdigit)
{
printf("Hay um... sorry what my i call you?");
scanf_s("%i", Gender);
printf("%lf \n" Gender ", if you may, please reread what i said, i asked you to give me a RANDOM NUMBER. \ncan you please explain to me why you gave me out of 1 through infinite numbers, a random letter? \n \n ");
};
我的问题是 ["%lf \n" Gender] 说它期待 [ ) ] 有人可以解释我做错了什么吗?
这里有几个问题:
scanf_s
需要一个指向您要存储读取值的位置的指针,因此它应该是scanf_s("%i", &Gender);
char
。 我不确定你到底想要什么,因为%lf
是一种非常奇怪的打印char
格式,但这就是我假设你想要的。 在这种情况下,您可能希望将Gender
移到末尾: printf("%lf \n...letter? \n \n", Gender);
. 这将在%lf
的 position 中插入Gender
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.