收到错误:"ISO C++ forbids comparison between pointer and integer [-fpermissive]"如何解决?

Getting error: "ISO C++ forbids comparison between pointer and integer [-fpermissive]" How do I fix?

本文关键字:-fpermissive 何解决 解决 integer and ISO 错误 C++ forbids pointer between      更新时间:2023-10-16

我正在制作一个将英语句子转换为猪拉丁语的程序。我不断在第 16 行收到错误"ISO C++禁止指针和整数 [-permissive] 之间的比较"。有什么帮助吗?

void wordfinder();
string word;
string engSent;
int x;
int main()
{
    cout << "Enter a sentence: ";
    getline(cin, engSent);
    string word = "";
    for (x = 0; x < engSent.length(); x++)
    {
        if (engSent[x] == " " || engSent[x] == "," || engSent[x] == ".")
        {
            wordfinder();
            word = "";
        }
    }
    return 0;
}
void wordfinder()
{
    word = engSent.substr(0,engSent[x]);
    cout << word;
}

检查以下字符而不是字符串:

if (engSent[x] == ' ' || engSent[x] == ',' || engSent[x] == '.')