Hi,
I have function which return whit en double* array.
I tried this to get the size : - double array[100];
-
-
double* Function()
-
{
-
// some code
-
return array;
-
}
-
-
int main(int argc, char *argv[])
-
{
-
double *getarray = Function();
-
int size = sizeof(getarray) / sizeof(getarray[0]);
-
}
If I print out the "getarray" variable it give some data, but the value of "size" is 0.
Can anyone explain what's wrong?
Thanks
Arepi
1 1353 YarrOfDoom 1,247
Recognized Expert Top Contributor
You're dividing the size of a pointer (so probably 1 byte as result) by the size of an element of the array (which is a double, and therefore more than one byte). The result of this would be less than zero, but since it's saved in a variable of the type int, that number is rounded down to zero.
As far as I know, the most common solution to this problem is to pass the length of the array along with the array itself.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Steven Bethard |
last post by:
Is there a good way to determine if an object is a numeric type?
Generally, I avoid type-checks in favor of try/except blocks, but I'm
not sure what to do in this case:
def f(i):
...
if x < i:...
|
by: moi |
last post by:
hi, i have an assignment to put 6 pseudo random numbers into an array to
simulate drawing 6 lottery numbers between 1-49. the code i have to do this
so far is listed below. i dont think its far...
|
by: Herrcho |
last post by:
in K&R Chapter 6.3
it mentions two methods to calculate NKEYS.
and points out the first one which is to terminate the list of
initializers with a null pointer, then loop along keytab until the...
|
by: Vasilis Serghi |
last post by:
Presently I define the number of lines to be expected in a file when
defining the array size and the initialisation of this array. This works
fine for now, but i'm sure that in the future this...
|
by: William Stacey [MVP] |
last post by:
int list = {1,2,3,4,5,6};
Function to randomize the list?
Cheers!
--
William Stacey, MVP
| |
by: mike |
last post by:
I have ListArray with number in Eg:
1, 1.456, 2.43, 4, 6.78
next i have a decimal variable containing one number EG:
1.786
Could someone please tell me how i find the "closest match" number...
|
by: gk245 |
last post by:
Trying to write a program that will figure out if a number is perfect
or not.
Here is my logic:
1) Read in the number
2) Split it up (number - 1)
3) Put all the split up numbers into an...
|
by: temper3243 |
last post by:
i,
If i have an array like {1,4, 10, 15 , 20 , 30 } of size n , now if i
want to search for number
25 , i should get 20 , if i search for number 11 i hould get 10 , if i
search for 4 i...
|
by: artev |
last post by:
If sort this work:
var myarray= new Array(10,16,35,"0.1",8,4,22,19,1,22,35,9,26,38,40);
with code
function function1(a,b)
{return a - b}
var order02=new Array();...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |