gpt4 book ai didi

c++ - 如何确定数组长度

转载 作者:行者123 更新时间:2023-11-30 01:40:06 24 4
gpt4 key购买 nike

<分区>

我正在尝试创建一个确定数组长度的函数。我的代码不起作用,请帮助!

#include <iostream>

using namespace std;

int ArrayLength(int Array[])
{
int i = 0;
while (Array[i] != NULL)
{
i++;
}
return i;
}

int main(void)
{
int test[5] = { 4,5,6,7,1 };
int testLen = ArrayLength(test);
cout << " test length = " << testLen;

return 0;
}

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com