setting a byte variable to "zero"?

I have a byte variable called "uint8_t data2[47]" which I would like to set to "0" (i.e: just contain the value zero).

Since I'm new working with bytes, does anyone have any suggestions on how to do this?

data2[47]=0;

Just don't put any quotes around it or it will assume you want the character "0"

You have a byte array called data2 which you would like to make element 47 equal to zero:

data2[47] = 0;

coding1227:
I have a byte variable called "uint8_t data2[47]" which I would like to set to "0" (i.e: just contain the value zero).

Do you mean the whole array?

memset (data2, 0, sizeof data2);
data2[47]=0;

Nice job of writing beyond the end of the array. 8)

Yeah ok.
I was assuming that data2[47] was the actual member of an array (of unknown size) that she wants to set to zero.

Reading it again it looks like that’s the whole array. :stuck_out_tongue:

Thank you so much, guys! This was really helpful & instructive. BTW, Nick, your trick worked flawlessly :slight_smile:

Nick’s code isn’t a “trick”. It’s based on his knowledge of the standard C library. There are a bunch of functions there waiting for you to use them. Get familiar with the Standard C library so you don’t reinvent the wheel.