Get specific element from an array

Hi
I have an array of bites and I am trying to find a way to get a specific number element from that array
e.g

byte data[] = {64, 65, 98, 2, 5, 6, 70, 8}; //array

byte output = command(data, 3) //gets third byte from 'data' and stores it in 'output'

Thanks in advance

byte output = data[2];  //note that the third byte is not entry 3

Wrap that in a function if you need to and pass the function the name of the array and the entry number to get and return but frankly it it simpler to just use the single line of code above

@OP

Array elements are numbered from left to right as 0, 1, 2, 3, ....

So,

data[0] = 64
data[1] = 65
data[2] = 98 //this is 3rd element when counting in decimal system; in binary system it is element 2
....................

How to get a specific element from an array? It is shown in Post#1.

Thanks a lot very helpful

If I may suggest, this is such a basic langage question that What might be really helpful would be for you to take a couple hours to read about the syntax / grammar and vocabulary of the C langage. That will be time well invested

J-M-L:
If I may suggest, this is such a basic langage question that What might be really helpful would be for you to take a couple hours to read about the syntax / grammar and vocabulary of the C langage. That will be time well invested

or even, the reference page.

The array reference page would indeed be a good starting point but I suspected (may be wrongly) more knowledge gaps in the language overall.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.