警告:语句无效 (C++)

warning: statement has no effect (C++)

本文关键字:C++ 无效 语句 警告      更新时间:2023-10-16

>警告:语句无效15号线我还必须显示 s1 中的所有字符,这些字符也可以在 s2 中找到。

    #include <iostream>
    #include <string.h>
    #include <ctype.h>
    using namespace std;
    int main()
    {
    char s1[250], s2[250];
    unsigned int i;
    cin.get(s1,250);
    cin.get();
    cin.get(s2,250);
    for(i=0;i<strlen(s2);i++)
        tolower(s2[i]);
    for(i=0;i<strlen(s1);i++)
        if(strchr(s2,tolower(s1[i])))
            cout<<s1[i];
    return 0;
}

std::tolower 按值获取参数并返回结果,因此不会修改输入值。