Noname
Noname

Reputation: 355

Size of a dynamic std array

I am quite new in C++ and at some point I try to figure out how to measure the size of a dynamic array. To be more specific lets say I define:

std::vector<int> dirichNodes;

and then after some operations I filled that vector. Later I would like to see its entries like:

    for (int i=0; i<????(size of dirichNodes vector); i++)
{

std::cout<<dirichNodes[i]<<std::endl;

}

what i would like to know is what to insert in the place of ???? here.

Any suggestions appreciated, thanks in advance.

Upvotes: 0

Views: 303

Answers (1)

Gio
Gio

Reputation: 3340

vector::size() will return the number of elements in a vector.

for (int i=0; i<dirichNodes.size(); i++)
{
    std::cout<<dirichNodes[i]<<std::endl;    
}

Upvotes: 4

Related Questions