I'd like to use a few for loops in C and use common index for these. I want to use pointer, because I will be able to free it later.
I thought about something like:
uint8_t *p = malloc(sizeof(uint8_t));
for (*p = 0; *p < 255; *p++)
{
// Instructions...
}
// A few loops...
free(p);
But this code doesn't work as I want. How can I fix it?
PS I'm a beginner in C's pointers.
uint8_t i;. There are uses of dynamic memory allocation, but this isn't it!uint8_there, instead of plainint?int, wait a secondintuses more memory, runs more slowly, introduces bugs, and wastes your time. It's a loss in almost every way. My advice to you is: just useint!