one function in my program won't work....
This project is a continuation of an old project my class did. the only difference is in the input, where they may enter up to 30 numbers instead of 6. This intersection function worked in the last program, but when I try to call it in this program, it just ends the program. It doesn't even make it through the function before quitting the program.
Here's the function code for intersection:
p.s.- the i array is a globally defined int variable above my main function
Code:
void intersection()
{
int number=0;
int count=0;
int intersect=0;
do
{
i[count]=99999;
count++;
}
while (count<=30);
count=0;
do
{
do
{
if (array_a[number]==array_b[count])
{
i[intersect]=array_a[number];
intersect++;
}
number++;
}
while (number<30);
number=0;
count++;
}
while (count<30);
number=0;
count=1;
do
{
do
{
if ((i[number]==i[count])&&(number!=count))
{
i[count]=99999;
count++;
}
else
{
count++;
}
}
while (count<=30);
number++;
count=0;
}
while (number<30);
cout<<"The intersection of A and B is:" <<endl;
intersect=0;
if (i[intersect]==99999)
{
cout<<"null set" <<endl;
}
else
{
cout<<i[intersect];
intersect++;
}
do
{
if (i[intersect]!=99999)
{
cout<<", " <<i[intersect];
intersect++;
}
}
while (intersect<30&&i[intersect]!=99999);
cout<<endl;
system("pause");
cout<<endl;
menu();
}
i just ran it again, and i get an error when executing intersection:
-------------------------------------------------------------------------------
Debug Error!
Program: ...Structures\c++ source files\Debug\proj2(trying to fix it).exe
abnormal program termination
(Press Retry to debug the application)
-------------------------------------------------------------------------------