array like pointer on the function for get the lenth of array.

i have this function

int ledParp(long *setLedParp){
Serial.println("setLeds: ");
Serial.println(setLedParp[0]);
Serial.println(setLedParp[1]);
Serial.println(setLedParp[2]);
Serial.println(setLedParp[3]);
Serial.println(setLedParp[4]);
Serial.println(setLedParp[5]);
Serial.println(setLedParp[6]);
// here is all good, i can see the data into the array.

Serial.print("length Array: ");
Serial.println(sizeof(setLedParp);
// here is the problem.
Some body know how i can get the legnth of array ?

much love, diego

Some body know how i can get the legnth of array ?

That function knows nothing about an array. It knows about an address in memory where some data is stored. If you want the function to know how much data is stored there, you have two choices. The simplest is to tell it.

The other way, that strings use, is to store in the "array" some value that says "Stop", like the NULL in a string (NULL terminated array of chars) does.

Depending on the nature of the "array", the stop-sign concept may, nor may not, be feasible.

Thk for your answer.
the array is:
long ledParpA[6];
the data into it is:

// Pin 12
ledParpA[0] = 12; // pin
ledParpA[1] = 0; // millis
ledParpA[2] = 1000; // delay.

// Pin 13
ledParpA[3] = 13; // pin .
ledParpA[4] = 0; // millis.
ledParpA[5] = 1000; // delay.

If the data is always in triplets, then a pin number of -1 would indicate that it was time to stop reading from the array. Passing the length of the array to the function may be more reasonable.

I'm not convinced you are using or populating arrays correctly.

I would have expected that you would know the length of the array when you declared it or intialized it- or that you might have declared a dummy value much bigger than the number of positions you might ever use.

Perhaps you could provide some context? Are you reading data of unknown length and then attempting to store it and act on it?

	// Pin 12
	ledParpA[0] = 12; // pin
	ledParpA[1] = 0; // millis
	ledParpA[2] = 1000; // delay.

	// Pin 13
	ledParpA[3] = 13; // pin .
	ledParpA[4] = 0; // millis.
	ledParpA[5] = 1000; // delay.

That is not a good use of arrays. What you're really trying to store here is an array of (pin, millis, delay) tuples. It would be better to define a struct to hold that set of values, and then define an array of those structs.

Unlike some other languages, a C array contains NO information about its own length.
The compiler knows the length of arrays (via sizeof()) within the scope of the array definition, but this is lost when you pass the array to other functions (and it becomes a pointer.) So you have to explicitly send the size, if you need it. Or use the special termination value. (and this is why C programs are subject to so many "buffer overflow" attacks.)

Normally, I would agree that this is better handled by a structure instead of an array. But there seems to be problems passing structures to functions using the Arduino IDE.
See: http://forum.arduino.cc/index.php/topic,41329.0.html
and http://forum.arduino.cc/index.php/topic,41848.0.html
and http://forum.arduino.cc/index.php?topic,229359.0.html
This is driving me crazy :stuck_out_tongue: at the moment and I am still trying to find a workaround that will compile.

DrWizard:
But there seems to be problems passing structures to functions using the Arduino IDE.

There's no 'seems' about it - the Arduino IDE developers didn't consider that people would ever need to use their own types in function signatures. I guess this tells you something about the level of thought that went into this feature. However, the workarounds for this IDE bug are well known.

the workarounds for this IDE bug are well known.

In short, put your structure definition and typedefs in a separate .h file, and #include that .h file from your sketch.

If you have time for a little read, here is an FAQ I wrote on the topic. http://arduino.land/FAQ/content/1/3/en/what-does-the-ide-change-in-my-sketch.html

At the bottom of the page is a link to another FAQ explaining why your code does not work.

thk every body for your answers !
the solution of strut sound good.
the solution of array with the length of array is working.
the solution with the marker on ther end of the array sound good too.

the last link:
http://arduino.land/FAQ/content/1/3/en/what-does-the-ide-change-in-my-sketch.html
i can not found... it is lost ?

much love, diego
thk a lot

i did it:

the stru is on the .h file
struct info3{
char *nombre[6];
long milis;
int pin;
long delay;
};

the definition the array is: (arrays of struct)
info3 infoA[3];

the objects definition of struct is with the data too.
info3 led1= {{"led1"},44,12,1021};
info3 led2= {{"led2"},22,22,1022};
info3 led3= {{"led3"},33,32,1032};

after i puting the object into the array:
infoA[0] = led1;
infoA[1] = led2;
infoA[2] = led3;

this is the calling to the function:
ledParp3(infoA,0); // primera fila del array.

function:
void ledParp3(struct info3 *dt, int cual) // recibe el tipo de datos info2 que es la estructura y lo muestra como el puntero dt.
{ Serial.print("setLeds2qqqqq: ");
Serial.println(cual);

Serial.println("Puntero_: ");

// for para mostrar el nombre hasta el carater de escape.
Serial.print(dt[cual].nombre[0]);
Serial.print(dt[cual].nombre[1]);
Serial.print(dt[cual].nombre[2]);
Serial.println(dt[cual].nombre[3]);

Serial.println(dt[cual].pin); //
Serial.println(dt[cual].milis); //
Serial.println(dt[cual].delay); //

}

    char *nombre[6];

Wrong. This is an array of 6 pointers, not an array of 6 chars. Lose the *.

thk ! is workin much better !

Figuring out what you actually have defined is pretty easy with a little practice (see: http://jdurrett.ba.ttu.edu/3345/handouts/RL-rule.html). Using the Right-Left Rule, the definition of:

 char *nombre[6];

is verbalized as: "nombre is an array of 6 pointers to char". By changing it to what Paul says, you get:

 char nombre[6];

which becomes: "nombre is an array of 6 chars".