I have writen some code for a HugeInteger class, but my input funtions will not work. It is suppose to check the array for negative numbers or 2 digit numbers. Since I randomize the numbers between 0 and 9 and checked them by not using the input funtion I know my problem has to be in code. I just don't see where.

void HugeInteger::input(int a[40])
{
   bool bad = false;
   for (int i=0; i<40; i++ )
   {
      if ( a[i] < 0 || a[i] >= 10)
      {
         cout << "Error! One of the numbers in array is negative or 
                           greater than 10." << endl;
         bad = true;
         i = 40;
      }
   }

   if ( bad = true )
   {
      for (int i=0; i<40; i++)
      {
         a[i]=0;
      }
   }
}

>>if ( bad = true )

You need to use the boolean operator == instead of the assignment operator =. That is a common error made by people coming from other languages such as VB which use = to be either assignment of boolean.

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.