SCANF的程序不在Visual Studio代码中执行
我是C编程的新手,每当我尝试使用SCANF运行代码时,我都不会执行。
#include <stdio.h>
int main()
{
int a,b,s;
printf("Enter the first no: \n");
scanf("%d",&a);
printf("Enter the second number: \n");
scanf("%d",&b);
s=a+b;
printf("%d",s);
}
I get this output:
[Running] cd "c:\msys64\mingw32\bin\" && gcc Prog1.c -o Prog1 && "c:\msys64\mingw32\bin\"Prog1
and this upon termination:
[Done] exited with code=1 in 6.586 seconds
The exact same code works without scanf.
#include <stdio.h>
int main()
{
int a=3,b=5,s;
printf("Enter first no: \n");
printf("Enter the second no: \n");
s=a+b;
printf("%d",s);
}
Output:
Enter first no:
Enter the second no:
8
This is what happens on executing in cmd prompt:
[1]: https://i.sstatic.net/o08a9.jpg
I'm new to C programming and whenever I try to run a code with the scanf it doesn't execute.
#include <stdio.h>
int main()
{
int a,b,s;
printf("Enter the first no: \n");
scanf("%d",&a);
printf("Enter the second number: \n");
scanf("%d",&b);
s=a+b;
printf("%d",s);
}
I get this output:
[Running] cd "c:\msys64\mingw32\bin\" && gcc Prog1.c -o Prog1 && "c:\msys64\mingw32\bin\"Prog1
and this upon termination:
[Done] exited with code=1 in 6.586 seconds
The exact same code works without scanf.
#include <stdio.h>
int main()
{
int a=3,b=5,s;
printf("Enter first no: \n");
printf("Enter the second no: \n");
s=a+b;
printf("%d",s);
}
Output:
Enter first no:
Enter the second no:
8
This is what happens on executing in cmd prompt:
[1]: https://i.sstatic.net/o08a9.jpg
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论