Contact: aviboots(AT)netvision.net.il
39,939 questions
51,876 answers
573 users
#include <iostream> #include <vector> int main() { // Direct initialization with characters std::vector<char> chars = {'a', 'b', 'c', 'd'}; for (char ch : chars) { std::cout << ch << ' '; } } /* run: a b c d */
#include <iostream> #include <vector> int main() { // Create vector of size 5, all initialized to 'x' std::vector<char> chars(5, 'x'); for (char ch : chars) { std::cout << ch << ' '; } } /* run: x x x x x */