简体   繁体   English

动态标准数组的大小

[英]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. 我是C ++的新手,有时我试图弄清楚如何测量动态数组的大小。 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. vector :: size()将返回向量中元素的数量。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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