Can anyone tell what cause the run time "Debug Assertion Failed!" error message? it has expression: sizeInBytes>count

int main()
{
int choice;        // for menu choice
string option;		// for repeat going back to menu option
Name name[300];
		
int i=0;          // count 

do{
	cout<<"Welcome!"<<endl;
	cout<<"1.Get the data"<<endl;
	cout<<"2.See the data"<<endl;
	cout<<"   1.forward"<<endl;
	cout<<"   2.backward"<<endl;
	cout<<"3.Add someone"<<endl;
	cout<<"4.Delete someone"<<endl;		
        cout<<"5.Edit an entry"<<endl;
	cout<<"6.Search for someone"<<endl;
	cout<<"   1.ID"<<endl;
	cout<<"   2.last name"<<endl;
	cout<<"7.Sort the data"<<endl
	cout<<"   1.ID"<<endl;
	cout<<"   2.last name"<<endl;
	cout<<"8.Information about the file"<<endl;
	cout<<"9.Save"<<endl;
	cout<<"10.exit"<<endl;
				
	cin>>choice;
	cout<<endl;

	switch(choice)
	{
	case 1:
	{
		int id;
		string lastName, firstName, phone;
		double amt;
		
		ifstream reader;
		reader.open("names.txt");

						             while(reader>>id>>lastName>>firstName>>phone>>amt)
		{
			
		name[i].set(id, lastName, firstName, phone, amt);
		i++;
		}
		reader.close();
		cout<<"Data read."<<endl;
		break;
		}
	case 2:
	{
		int secPick;
		cout<<"1.forward    2.backward"<<endl;
	        cin>>secPick;
		if(secPick==1)
		{
		showlist(name, i);
		cout<<endl;
	}

		else if(secPick==2)
		{
		showlistBackward(name, i);
		cout<<endl;
		}

		else
		{
		cout<<"You have entered a wrong option"<<endl;
		exit(1);
		}
		break;
		}
		case 3:
				
		addName();
		break;

		case 9:
		save(name, i);
		//cout<<"Sorry, not yet implemented.";
		break;

	case 10:
		exit(0);

		default:
		cout<<"Sorry, this input is not an option";
		exit(1);
				
		}
		cout<<"Do you want to go back to the main menu? (Enter yes or no)";
		cin>>option;
		}while(option=="yes" || option=="Yes");

		return 0;
	}

>Can anyone tell what cause the run time "Debug Assertion Failed!" error message?
Usually it means you caused a library function to break by doing something that it's assuming won't happen. This can also happen in your own code if you use assertions (which is rare, sadly). Step through your code to find out where it's throwing the error and you'll be well on your way to figuring out what's wrong.

Build your program in debug mode, and run in debug mode, you will find exact line which is causing assertion failure.

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.