[英]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 ");
};
my problem is with ["%lf \n" Gender] saying that its expecting a [ ) ] can someone please explain what i am doing wrong?我的问题是 ["%lf \n" Gender] 说它期待 [ ) ] 有人可以解释我做错了什么吗?
A few issues here:这里有几个问题:
scanf_s
takes a pointer to where you want to store the read value, so it should be scanf_s("%i", &Gender);
scanf_s
需要一个指向您要存储读取值的位置的指针,因此它应该是scanf_s("%i", &Gender);
char
into a string.char
。 I'm not sure exactly what you want from this, since %lf
is a really weird format for printing a char
, but that's what I'm assuming you want.%lf
是一种非常奇怪的打印char
格式,但这就是我假设你想要的。 In that case, you would want to move Gender
to the end: printf("%lf \n...letter? \n \n", Gender);
Gender
移到末尾: printf("%lf \n...letter? \n \n", Gender);
. Gender
in the position of %lf
.%lf
的 position 中插入Gender
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.