簡體   English   中英

得到錯誤:“ISO C ++禁止指針和整數之間的比較[-fpermissive]”如何修復?

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

我正在制作一個將英語句子轉換成豬拉丁語的程序。 我一直在第16行收到錯誤“ISO C ++禁止指針和整數[-fpermissive]之間的比較”。任何幫助?

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] == '.')

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM