the error read EXC_BAD_ACCESS (code = 1, address...), can anyone help me figure out this error.
#include <iostream>
#include <fstream>
using namespace std;
int menu();
int Diatom();
int Phytoplankon();
int main()
{
bool Exit = false;
for (;;)/>
{
int choice = menu();
switch(choice)
{
case (1):
Diatom();
break;
case (2):
Phytoplankon();
break;
case (3):
Exit = true;
break;
case (4):
menu();
break;
default:
cout << "Please Selete again!" << endl;
} // end switch
if (Exit == true)
break;
} // end
return 0;
} // end main
int menu()
{
int choice;
cout << "Welcome The Algae Information Recoder Program " << endl;
cout << "(1) Enter Information for a Diatom " << endl;
cout << "(2) Enter Information for a Phytoplankton " << endl;
cout << "(3) Quit Program " << endl;
cout << "(4) Redisplay Menu " << endl;
cin >> choice;
return choice;
}
int Diatom()
{
char filename[80];
cout << "Enter File Name: ";
cin.get(filename, 79);
ofstream fout(filename);
unsigned long int const MaxLength = 4294967295;
char Species[MaxLength];
char Locationfound[MaxLength];
char Desciption[MaxLength];
//open for writing
cout << "Enter The Taxanomic Name For The Diatom: ";
cin.ignore(1, '\n');
cin.getline(Species, MaxLength);
fout << Species << "\n";
cout << "Enter The Location That The Species Was Found: ";
cin.ignore(1,'\n');
cin.getline(Locationfound, MaxLength);
fout << Locationfound;
cout << "Add a Description Regarding the Diatom: ";
cin.ignore(1, '\n');
cin.getline(Desciption, MaxLength);
fout << Desciption;
fout.close();
return menu();
}
int Phytoplankon()
{
unsigned long int MaxLength = 4294967295;
char Species[MaxLength];
char Locationfound[MaxLength];
char Desciption[MaxLength];
char filename[80];
cout << "Enter File Name: ";
cin.get(filename, 79);
ofstream fout(filename); //open for writing
cout << "Enter The Taxanomic Name For The Diatom: ";
cin.ignore(1, '\n');
cin.getline(Species, MaxLength);
fout << Species << "\n";
cout << "Enter The Location That The Species Was Found: ";
cin.ignore(1,'\n');
cin.getline(Locationfound, MaxLength);
fout << Locationfound;
cout << "Add a Description Regarding the Diatom: ";
cin.ignore(1, '\n');
cin.getline(Desciption, MaxLength);
fout << Desciption;
fout.close();
return menu();
}
Correction the error is pointing to line 62
cout << "Enter File Name: ";

New Topic/Question
Reply



MultiQuote





|