So, in my function when I try to return a long
, it acts like I'm returning an int
. This mostly comes into play when I'm trying to return a long
that has more than 10 digits
, it will return an int
limited to 10 digits
.
For example my code is trying to find the greatest number within an array of long
s so,
#include<stdio.h>
#include<stdlib.h>
long maximum(long arr[])
{
long i, max;
for(i = 0; i < sizeof(arr); i++)
{
//This sets the initial number to the maximum
if(i == 0)
{
max = arr[0]
}
else if(arr[i] > max)
{
max = arr[i];
}
}
return max;
}
When I do a printf
in the array right before the return it prints out the correct long
with all its digits, but when I return it and try to use this function to return the long
in another function then it will only return an int
limited to 10 digits
. I feel like there might be something obvious I'm missing but I don't know what it is.