C语言,scanf语句不知道为什么被跳过了

C语言,scanf语句不知道为什么被跳过了,第1张

因为我们在输入第一组的2个数时会输入“回车”,这个回车锋迹会被你第二个“scanf”函数捕获,你银档并只要在第二个“scanf”语句前加一句“getchar()”就行了,代码如下:

#include "stdio.h"

int main(){

int a,b

char Operator

printf("please input two number:")

scanf("%d %d",&a,&b)

printf("please input Operater(+ or -):")

getchar()

scanf("%c",&Operator)

switch(Operator)

{

case '+':

printf("%d+%d=%d\n",a,b,a+b)break

case '-':

printf("%d-%d=%d\n",a,b,a-b)break

default :

printf("蠢答Input error\n")

}

return 0

}

Loaded 'ntdll.dll', no matching symbolic information found.

Loaded 'C:\Windows\SysWOW64\kernel32.dll', no matching symbolic information found.

Loaded 'C:\Windows\SysWOW64\KernelBase.dll', no matching symbolic information found.

这些跟你的程序没关系。它是vs系列编程软件编译时,默认的要带激去找相关模块的符号文件。这个符号文件用于调试,一般编程不需要。

看情况你的代码是正常退出了。问题就陵行仿出现在scanf上。建议你不要使用这个函数,在循环输入时使用它不行。用尺纤gets就好了 。

scanf("%d %s %f %f ",&(p+i)->num,(p+i)->name,&(p+i)->score1,&(p+i)->score2,&(p+i)->score3)//这段代码里面从扰旅键盘只读取了4个值,却要赋值给5个成员,少了一个%f。缓穗凳族铅

scanf("%d %s %f %f %f",&(p+i)->num,(p+i)->name,&(p+i)->score1,&(p+i)->score2,&(p+i)->score3)


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/12353862.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-24
下一篇 2023-05-24

发表评论

登录后才能评论

评论列表(0条)

保存