Computing length of array

后端 未结 10 1316
萌比男神i
萌比男神i 2020-12-19 13:37

I have a C++ array declared as mentioned below:

CString carray[] =
{
        \"A\",
        \"B\",
        \"C\",
        \"D\",
        \"E\"
}
10条回答
  •  难免孤独
    2020-12-19 14:04

    That's not runtime, it's compile time. The way you're using is correct. Note that Visual Studio defines a _countof function that does the same.

    At runtime, the length cannot be determined. You either keep a length yourself, or use std::vector

提交回复
热议问题