O
O
oftywave2020-12-08 19:50:20
C++ / C#
oftywave, 2020-12-08 19:50:20

Is it possible to shorten this cycle?

is it possible to shorten this cycle?

std::vector<std::string> vec_s = { "a", "b", "c" };

for(int index_vec_s = 0; index_vec_s <= vec_s.size() - 1; index_vec_s++)
//std::cout для примера// std::cout << vec_s[index_vec_s].data() << std::endl;

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Armenian Radio, 2020-12-08
@oftywave

using namespace std;
for(const auto& i:vec_s)
{
    cout << i << '\n'; //выводим \n чтобы не сбрасывать буфер терминала на каждой строке
}
cout << flush;

M
maaGames, 2020-12-09
@maaGames

index_vec_s <= vec_s.size() - 1
Looks funny.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question