On Thu, Apr 3, 2008 at 2:36 PM, alex_merlin_1985
<[EMAIL PROTECTED]> wrote:
> Hi!
>
> Could you give me an idea about how can i check if in an array is set
> a key, for example:
>
> #include <conio.h>
> #include <iostream.h>
>
> void main()
> {
> int x[10];
>
> x[0] = 1;
> x[1] = 2;
> }
> i need a method to check if is set a value or exists x[2]
There is none, since if it's allocated it's set -> if uninitialized,
then for some random (garbage) value.
The reasonable solution for this is to pre-initialize all elements to
a known invalid value (line 0 or -1), and check them against that
value.
--
Tamas Marki