Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/161.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 非常简单的c++;对于声明,但它不能?_C++_Xcode_For Loop_Cout - Fatal编程技术网

C++ 非常简单的c++;对于声明,但它不能?

C++ 非常简单的c++;对于声明,但它不能?,c++,xcode,for-loop,cout,C++,Xcode,For Loop,Cout,我的问题很简单。我在c++程序中有一个“for”语句,编译时会忽略我的cout 我正在使用xcode,使用xcode编译,下面是我的代码: #include <iostream> using namespace std; int main () { cout << this prints" << endl; for(int i=0; i>10; i++) { cout <&

我的问题很简单。我在c++程序中有一个“for”语句,编译时会忽略我的cout

我正在使用xcode,使用xcode编译,下面是我的代码:

#include <iostream>
using namespace std;

    int main () 
    {
      cout << this prints" << endl;
      for(int i=0; i>10; i++)
       {
         cout << "this doesn't" << endl;
       }
     return 0;
    }
#包括
使用名称空间std;
int main()
{
库特
您将
i
初始化为
0
,然后仅当
i
大于
10
时才进入循环体


只要条件
i>10
为真,循环就会循环,直到条件
i>10
为真。这就是C++中所有循环的工作方式:
for
while
,和
do/while
您的循环条件是向后的。您希望它是
i<10
您已经得到了l的条件oop不正确。这应该可以工作。请检查以下内容:

#include <iostream>
using namespace std;

int main () 
{
    cout << "this prints" << endl;
    for(int i=0; i<= 10; i++)   // ------> Check the change in condition here
    {
        cout << "this doesn't" << endl;
    }
    return 0;
}
#包括
使用名称空间std;
int main()
{
库特
#include <iostream>
using namespace std;

int main () 
{
    cout << "this prints" << endl;
    for(int i=0; i<= 10; i++)   // ------> Check the change in condition here
    {
        cout << "this doesn't" << endl;
    }
    return 0;
}