2012-02-18 102 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){

相關問題