How do you compare a 1D array with a 2D array?

I have a pointer being passed as a reference to a function. And this pointer points to 0th element of a 1D array. Now I want to compare it with an 2D array.

This 2D array is a list that will keep generating if any 1D array that is being passed isn't already saved in that list.

How can I implement this?

Multiple calls to "memcmp"

Each element of array needs to be compared. The elements of the array hexadecimal padded to two digits "%02x".

The scenario is as below.

A[0] A[1] A[2] A[3] --- pointer points to first element of this array

B[0] B[1] B[2] B[3] --- array inside the function

Compare A and B. If A == B then save A into B else don't save. So the array B grows as time goes on. Let say until the element size of rows of array B = 2.

B[0][0] B[0][1] B[0][2] B[0][3] --- grows to something like this B[1][0] B[1][1] B[1][2] B[1][3] B[2][0] B[2][1] B[2][2] B[2][3]

So, how to implement this scenario?

See reply #1

If A == B then save A into B

If they are the same, why do you need to save duplicate data?

grows to something like this

How, exactly, are you going to make the array "grow"? Feed it some array fertilizer?

If they are the same, why do you need to save duplicate data?

Because A is stored as a temporary buffer when I receive a data and it is discarded right now. So I want to save them. Its like I have a server which is connected to 9 nodes. So I want to the server to collect all the nodes IP before sending data.

How, exactly, are you going to make the array "grow"? Feed it some array fertilizer?

I don't know if you meant it sarcastically or not. I mean it will become a table once all the 9 IPs are stored. In the end it will be array[8][15].

Thanks

Is this the IP address question again? Why 15 bytes to store an IP address when four is perfectly sufficient?

array[8][15].

All nine?

Why 15 bytes to store an IP address when four is perfectly sufficient?

Because that is how it is read from the contiki OS I am using to implement the wireless section of what I am doing.

The elements of the array hexadecimal padded to two digits "%02x".

I'll ask again - why fifteen bytes to store an IP address, when four bytes will suffice? You do know RAM is very limited?

I don't know if you meant it sarcastically or not. I mean it will become a table once all the 9 IPs are stored. In the end it will be array[8][15].

In the beginning, too. Do not plan to create a dynamic mess.

The array WILL be[9][4]!