natkw1@yahoo.com.au wrote:[color=blue]
> Hi,
>
> #include <stdio.h>
> #include <ctype.h>[/color]
You're not using anything from ctype.h, then why include it?
[color=blue]
>
> #define ROW 2
> #define COL 5
>
> void init_array();[/color]
When you declare a prototype, make sure you declare the parameters too,
improves readability. And if I'm not wrong, then a C compiler assumes
integer parameters when none are specified in the prototype.
[color=blue]
>
> main ()[/color]
It should be "int main(void)"
[color=blue]
> {
> char array[ROW][COL];
>
> init_array(array);
> return 0;
> }
>
> void init_array(char data[][])[/color]
For unsized arrays, you can leave out only the leftmost dimension.
You must specify the rest. So correct the above as:
"void init_array(char data[][COL])"
[color=blue]
> {
> int r, c;
>
> for (r=0; r<=ROW; r++)
> {
> for (c=0; c<=COL; c++)
> {
> data[r][c] = NULL;[/color]
Use "data[r][c] = 0;". NULL is defined as a pointer to nothing, the
above statement will cause this warning: "assignment makes integer from
pointer without a cast"
[color=blue]
> }
> }
> }
>
> But when I try to compile with gcc, I'm getting this message
> a2.c: In function `init_array':
> a2.c:28: arithmetic on pointer to an incomplete type
>
> Can anyone explain what the error means in english ?
> What am I doing wrong ?
>
> Nat
>
> I've tried posting to comp.lang.c.moderated but I must have done
> something incorrect as it hasn't been posted yet. My appologies if it
> appears twice.
>[/color]
cheers,
forayer
--
If you would be a real seeker after truth, it is necessary that at least
once in your life you doubt, as far as possible, all things."
-- Rene Descartes