【发布时间】:2015-12-26 16:19:30
【问题描述】:
1. int wordCount;
2. for (int x = 0; x < sen.length(); x++)
3. {
4. if (sen.at(x) == " ") {wordCount++;}
5 }
每次字符串中的元素为空时,我都会尝试增加 wordCount。但是每当我运行代码时,它都会在第 4 行生成一个错误,上面写着ISO C++ forbids comparison between pointer and an integer。
谁能告诉我如何解决这个问题以及为什么我不断收到错误。
【问题讨论】: