1.sizeof用于判断数据占据的内存字节数。

如:sizeof(int)的为4。

因此,判断数组的元素个数写法如下:

num=sizeof(array)/size(a[0]);

 

2.判断string类型元素个数

string是字符串,判断字符串中的字符个数

num=string.size();

 

3.判断vector数组的元素个数

vector创建动态数组

num=vector.size();

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-15
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-07
  • 2021-12-25
  • 2021-07-26
  • 2022-12-23
  • 2021-08-26
  • 2022-12-23
相关资源
相似解决方案