C语言 编程错误

日期:2016-10-28 21:44:46 人气:1

C语言 编程错误

调试了一下,问题在于字符串输入后没有清stdin流残余数据,故变量ch没有获得正确值。 修改代码和注释如下: #include #include int Strchr(char s[],char ch);int main(){ char ch; int y; char s[1000]; printf("Please input a string:"); scanf("%s",&s); getchar(); //清除stdin流的残留数据 p
    A+
热门评论