uint8_t *var;
var=//something;
Now I want to loop through each element of this var how to do this please help
Make loop like in plain C. uint8_t *var
is just an C array.
for (uint8_t i = 0; i < ARRAY_LENGTH; ++i) {
var[i] = ...; // Do whatever you want
}
For example
uint8_t *v = (uint8_t *)malloc(5 * sizeof(uint8_t));
for (uint8_t i = 0; i < 5; ++i) {
v[i] = i;
}
for (uint8_t i = 0; i < 5; ++i) {
NSLog(@"%d\n", v[i]);
}
free(v);
Note that uint8_t
is the same as unsigned char
:
#ifndef _UINT8_T
#define _UINT8_T
typedef unsigned char uint8_t;
#endif /*_UINT8_T */
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With