How to insert the same string several times in deque using C++

1 Answer

0 votes
#include <iostream>  
#include <string>  
#include <deque> 

int main()
{
	std::deque<std::string> dq;

	dq.assign(5, std::string("c++"));

	for (auto elem : dq) {
		std::cout << elem << ' ';
	}
	std::cout << std::endl;

	return 0;
}

/*
run:

c++ c++ c++ c++ c++

*/

 



answered Jan 4, 2018 by avibootz

Related questions

1 answer 285 views
1 answer 155 views
1 answer 196 views
1 answer 178 views
1 answer 173 views
1 answer 196 views
...