c++ - 警告 : statement has no effect (C++)

标签 c++

警告:声明无效 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按值获取它的参数并返回结果,因此不会修改输入值。

关于c++ - 警告 : statement has no effect (C++),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34837098/

相关文章:

c++ - Qt C++ QRegExp 解析字符串

c++ - 为什么 C++ StringStream 跳过输入文件中的第一个数字,但显示其余数字?

c++ - 如何在 DLL(动态链接库)中运行 MPI

c++ - 将电影转换为 OpenNI *.oni 视频

c++ - 降低构建大小

c++ - 什么是 ATOMIC_FLAG_INIT 以及它应该如何使用?

c++ - 如何检查 key 是否存在于 std::map 中并在 if 条件下获取 map::iterator?

python - 使用 OpenCV 3.4 加载 CNN tensorflow 模型时出错

c++ - 为未定义函数选择正确重载的编译器差异

c++ - 我将如何安排具有哨兵值的多个 cin?