Hi am new to programming and I really need some how to check an array to see if a number already exists. I read the tutorials about random number genertors but I am just not getting how to check if the random generator already generated that number somewhere else in the array.

Thanks,

Laurie

You can search for a number easily:

int array[BIG_SIZE];
int n = 0;

// ...

int r = rand();
int i;

for ( i = 0; i < n; i++ ) {
  if ( r == array[i] )
    break;
}

if ( i == n )
  array[n++] = r;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.