2012-02-18 86 views
1

嗨我通过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; 
} 
+2

关系运算符==,!=,<, >,<=, and > =。没有=>或= <运算符(在C/C++中)。 – DavidO 2012-02-18 00:14:16

回答

3
while (i=<23){ 
     ^^ 

尝试while (i <= 23)代替。

1

while (i=<23){应该while(i<=23){

相关问题