Closed. This question is off-topic。它当前不接受答案。
想改善这个问题吗? Update the question,因此它是on-topic,用于堆栈溢出。
2年前关闭。
所以基本上这是代码,我不知道我的错误在哪里?
输入号码后。该程序停止工作
想改善这个问题吗? Update the question,因此它是on-topic,用于堆栈溢出。
2年前关闭。
#include<stdio.h>
int main(void)
{
int a;
printf("enter your number\n");
scanf("%d\n", a);
printf("your number is %d\n", a);
}
所以基本上这是代码,我不知道我的错误在哪里?
输入号码后。该程序停止工作
最佳答案
您必须将a的指针传递给scanf并从scanf中删除\ n。
如果您想换行,请在您的电话号码之前添加\ n ...
代码变成这样
#include<stdio.h>
int main(void)
{
int a;
printf("enter your number\n");
scanf("%d", &a);
printf("\nyour number is %d\n", a);
}
关于c - 使用变量C编程时,第二个printf不起作用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/46837952/