简体   繁体   中英

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.

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;    
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM