Computing length of array

后端 未结 10 1300
萌比男神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 13:47

    The best way is to use a macro and use that where ever you want the size.

    #define MAX_ROWS 1048
    int array[MAX_ROWS];
    

    This way you can use the MAX_ROWS even in a function where the array is passed as an argument.

提交回复
热议问题