C++ for-loop structure with multiple variable initialization

后端 未结 5 1479
长情又很酷
长情又很酷 2021-01-17 12:01

On the 2nd for-loop, I get the following error from gcc:

error: expected unqualified-id before \'int\'

I\'m not sure what I\'m missing. I\

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-17 12:29

    Don't declare int after comma use,

    for (int i = 0,col = 0; i < values.size(); i++, col++) {
      if (col > 10) { std::cout << std::endl; col == 0; }
      std::endl << values[i] << ' ';
      }
    }
    

提交回复
热议问题