Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

vector with pinter cout c++

#include <iostream>
#include <vector>

using std::cout; using std::cin;
using std::endl; using std::string;
using std::vector;

template<typename T>
void printVectorElements(vector<T> *vec)
{
    for (auto i = 0; i < vec->size(); ++i) {
        cout << vec->at(i) << "; ";
    }
    cout << endl;
}

int main() {
    vector<string> str_vec = {"bit", "nibble",
                              "byte", "char",
                              "int", "long",
                              "long long", "float",
                              "double", "long double"};

    printVectorElements(&str_vec);

    return EXIT_SUCCESS;
}
Source by www.delftstack.com #
 
PREVIOUS NEXT
Tagged: #vector #pinter #cout
ADD COMMENT
Topic
Name
2+1 =