## Reliably determine the number of elements in an array

Every C programmer can determine the number of elements in an array with this well-known macro:

#define NUM_ELEMS(a) (sizeof(a)/sizeof 0[a])
Here is a typical use case:

int numbers[] = {2, 3, 5, 7, …

## In Perl, how can I find the index of a given value in an array?

\$VAR1 = [
‘830974’,
‘722065’,
‘722046’,
‘716963’
];
How can I calculate the array index for the value “722065”?

I have an array

Array(
 => Array
(
 => 33
[user_id] => 33
 => 3
[frame_id] => 3
)

 => Array
(
 => 33
[…

## Replace NaN’s in NumPy array with closest non-NaN value

I have a NumPy array a like the following:

>>> str(a)
‘[ nan nan nan 1.44955726 1.44628034 1.44409573\n 1.4408188 1.43657094 1.43171624 1.42649744 1.42200684 …

## What is the default value of a member in an array?

I instantiate an array like this:

int array[] = new int;
What are the default values for those four members? Is it null, 0 or not exists?

## In Perl, how can I generate all possible combinations of a list?

I have a file with a list, and a need to make a file that compares each line to the other. for example, my file has this:

AAA
BBB
CCC
DDD
EEE

I would like the final list to look like this:

## Find size of array without using sizeof in C

I was searching for a way to find the size of an array in C without using sizeof in C and I found the following code:

int main ()
{
int arr;
printf (“%d\n”, (&arr) – arr);

## Split vector in MATLAB

I’m trying to elegantly split a vector. For example,

vec = [1 2 3 4 5 6 7 8 9 10]
According to another vector of 0’s and 1’s of the same length where the 1’s indicate where the vector should be …

## Writing & Appending arrays of float to the only dataset in hdf5 file in C++

I am processing number of files, each processing of the file will output several thousand of arrays of float and I will store the data of all files in one huge dataset in a single hdf5 for further …

## C – Difference between “char var[]” and “char *var”?

I am expecting that both following vectors have the same representation in RAM:

char a_var[] = “XXX\x00”;
char *p_var = “XXX”;
But strange, a call to a library function of type f(char argument[]) …