Mail Archives: djgpp/1997/10/24/14:46:37
Brett Porter wrote:
>
> > Little know fact (well, not really) is that you can initalize
> > your array as follows..
> >
> > bool scrn[640][480] = {0};
> >
> Are you sure? I don't ever recall seeing this done.
I have. But I don't find it good practice. Either don't initialize your
elements, or initialize them all (except for character arrays that
receive a string as initializer).
> > You could initalize every variable this way as well (Even 2D, 3D... nD
> > arrays) by just putting a comma (,) after ever variable.
> > Ex.
> >
> > bool foo[2][3] = { 0, 1, 0, 1, 0, 1};
> >
> I'm almost certain this won't work, I think it should be {{0,1},{0,1},{0,1}}
This *will* work, but the compiler will issue a warning about it. What
you write is the most correct way.
> > only sets the first item of the array to 1 but the rest to 0. As for how
...
> This is not really a standard as mar as I know. What is wrong with just
> memset(foo, 0, sizeof(foo)); ?
That you are assuming things about the internal representation of bool.
Which is certainly not standard!
--
+----------------+
| Vik Heyndrickx |
+----------------+
- Raw text -