【问题标题】:expected primary-expression before '<' token error'<' 标记错误之前的预期主表达式
【发布时间】:2012-03-09 09:06:15
【问题描述】:

嗨,我正在回顾 C 编程练习,在这个特定的程序中,我在第 8 行(While 循环)的“

#include <stdio.h>
#include <iostream>
using namespace std;

int main(){
   int number, i=8;
   cout <<"Please enter all numbers from 8-23\n";
   cout <<"Start Now: ";
   while (i=<23){
          cin>>number;
          cout<<"Next: ";
          if (number!=i){
             cout<<"That was the wrong, Please enter: "<<i<<endl;
          }
         else 
           i++;
    }
    cout<<"Congratulations!!\n";
return 0;
}

【问题讨论】:

  • 关系运算符为 ==、!=、、=。没有 => 或 =

标签: c++


【解决方案1】:
while (i=<23){
        ^^

改用while (i &lt;= 23)。

【讨论】:

    【解决方案2】:

    while (i=&lt;23){ 应该是while(i&lt;=23){

    【讨论】:

      猜你喜欢
      • 2013-01-13
      • 2017-09-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多