C++无法识别我的for循环

C++无法识别我的for循环,c++,C++,我可能只是错过了一些非常简单的东西,但当我运行我的程序时,它完全跳过了for循环,为什么 #include <iostream> using namespace std; int main() { //user input int largest=0, num, i=0; cout << "Please enter 10 numbers to find the largest one" << endl; for (i=0, i

我可能只是错过了一些非常简单的东西,但当我运行我的程序时,它完全跳过了for循环,为什么

#include <iostream>
using namespace std;

int main()
{
    //user input
    int largest=0, num, i=0;
    cout << "Please enter 10 numbers to find the largest one" << endl;
    for (i=0, i < 10; i++;)
    {
        cout << "Enter number " << i+1 <<":";
        cin >> num;
        if (num > largest)
        largest = num;

    }
    cout << "The largest number is: " << largest;
return 0;
}

使用上面的方法,您可以在for循环的Evaluate部分使用i++

0 == false 
试着这样做:

for (i=0 ; i < 10; i++) 

您的语法错误:for循环的形式应为:

for ( init; condition; increment ) 
注意:各条款之间用;分隔;。但你写道:

for (i=0, i < 10; i++;)

它的功能与您预期的一样。

对于i=0,i<10;i++;=>对于i=0;i<10;i++表示i=0,i<10;i++;=>对于i=0;i<10;我++哈哈,很好的欺骗评论;检查foror i++==>++i中的逗号和分号,让循环运行数十亿次:PI知道这是非常愚蠢的事情。非常感谢!
for (i=0, i < 10; i++;)
for (i=0; i < 10; i++)