[prog] mutlitdimensional arrays in C

aec brat at magma.ca
Sat Oct 9 11:17:17 EST 2004


On Sat, Oct 09, 2004 at 04:57:45PM +0200, Isabelle Hurbain wrote:
 
> Well, you actually do pointers without knowing it ;) as arrays are, in
> fact, pointers. I guess you'll see that a bit later in the book so I
> don't want to confuse you right now.
> 
> The warning (not an error because an error would make the compilation
> fail) comes from your line :
>   return n;
> The thing is, you declared your return type as "int" and what you try to
> return is n, which you declared as type int[5][4]. Hence the error :
> int[5][4] is, as I told before, a pointer. So you are doing exactly what
> gcc suggests to you : it waits an integer and you give him a pointer.
> You don't actually need to return anything the way you do things. By the
> way you can see that you do not use your return value ;)
> The simplest thing that will make the warning disappear is to delete the
> return n; line and put the return type to void.
> 
> Hoping to be clear (do not hesitate to growl if I'm not ;) )
> 
> Isa

Yep, I see now whats going on, I did just what you said and it
compiles now with the function type void and no return.

I have to do structures next then pointers so it will be a while :) 


-- 
Angelina Carlton


More information about the Programming mailing list