How to determine the size of an array of strings in C++?

后端 未结 8 687
野的像风
野的像风 2020-12-30 06:57

I\'m trying to simply print out the values contained in an array.

I have an array of strings called \'result\'. I don\'t know exactly how big it is because it was au

8条回答
  •  北海茫月
    2020-12-30 07:16

    Better use std::vector instead of a raw array. Then you don't have to manually manage the arrays memory and you can use the size() method if you want to know the number of elements.

    If you use a dynamically allocated raw array you are expected to keep track of its size yourself, the size cannot be obtained from the array. Best save it in an extra variable.

提交回复
热议问题