Can anyone tell me how to create arrays in nes-c. Also i would like to print them. I just saw on google that this is a way but its giving me errors. uint8_t i;*
uint8_t in[16] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
A bit late to the party, but maybe it's still useful to answer this.
Creating an array
Arrays in nesC are defined the same way as in normal C language, since nesC is simply an extension of C:
type arrayName [ arraySize ];
I use tutorialspoint for concise tutorials on C, but you can find explanations on a multitude of websites. In your case I would define the array like this:
uint8_t in[16];
Initializing the array with zeroes is best done with the command memset:
memset(in, 0, sizeof(in));
Why? It's clean code, works efficiently, and doesn't need adjusting when you decide to increase the size of the array.
Printing an array
For this I'll refer you to the TinyOS Printf Library tutorial, this explains how you print stuff to the console in TinyOS. I assume you're working with this since you're asking a nesC question.
Printing an array can be done through a simple for-loop.
for (i = 0; i < sizeof(in); ++i) {
printf("%u", in[i]);
}
printfflush();
Good luck!