I apologize for the simplicity of my question and its similarity to questions already asked. I've looked at questions like it and researched for hours now, and I haven't been able to straighten out whatever misconceptions I have that prevent me from understanding it.
In the following excerpt of code, the warning 'assignment from incompatible pointer type [enabled by default]' occurs at the equals sign on the line commented 'Warning'.
char * readFile(int width, int height)
{
char mapArray[width][height];
char *p;
p = mapArray; // Warning
return p;
}
Why is that?
What I currently understand is that 'mapArray' contains the address of the first element of a 2D array of chars. 'p' is defined such that it will, in future, contain the address of another place in memory where a char exists. The value of 'p' is then set to the current value of 'mapArray', so it now contains the address of the first element of said array. The function returns the value of p, which is an address, i.e. a pointer, to a char in memory.
I'd greatly appreciate if someone could tell me where my understanding falls down, and where the incompatible pointer type enters into this.