动态分配的整型数组的大小 [英] Size of a dynamically allocated integer array

查看:94
本文介绍了动态分配的整型数组的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我处理类型的函数:

 int xyz(int input[])

我没有访问的主要功能,因此没有对所述阵列的大小想法。
我怎样才能找到输入数组的大小?
有没有办法知道其中数组结束?
的sizeof(输入)/ sizeof的为(int *)正在给1作为输入,基本上是一个指针。

I do not have access to the main function and therefore have no idea about the size of the array. How can i find the size of the input array? Is there any way to know where the array ends? sizeof(input)/sizeof(int*) is giving 1 as input is basically a pointer.

推荐答案

如果主叫方不提供有关数组大小的信息,然后有没有办法让在功能上xyz的大小()。

If the caller doesn't provide the size information about the array then there's no way to get the size in function xyz().

您可以通过在另一个变量的大小信息(或阵列的elemnt)。

You can pass the size information in another variable (or as an elemnt of the array).

int xyx(int abc[], size_t len)
{

}

这篇关于动态分配的整型数组的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆