I thought I understood c and pointers but was just debugging someone elses code that I thought should not work but did. As a (crude) example....
void clear_buffer(char* buff, int len)
{
while(len)
{
*buff++ = ' ';
len--;
}
}
main()
{
char buffer[10];
clear_buffer(&buffer,10); // 1. what I found, it still works...
clear_buffer(buffer,10); // 2. what I would have wrote
}
What suprised me was that both calls above do work exactly the same way. The first one gives a compiler warning (incompatible pointer types) but it still builds and runs correctly. So my question is: is this the expected behaviour in C or is it just the compiler I am using being clever and fixing a bug? fwiw, this is using the microchip xc16 compiler.