Assertion Failed

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Nov 2007
Posts: 227
Reputation: k2k is an unknown quantity at this point 
Solved Threads: 0
k2k k2k is offline Offline
Posting Whiz in Training

Assertion Failed

 
0
  #1
Jan 28th, 2008
Can anyone tell what cause the run time "Debug Assertion Failed!" error message? it has expression: sizeInBytes>count


  1.  
  2. int main()
  3. {
  4. int choice; // for menu choice
  5. string option; // for repeat going back to menu option
  6. Name name[300];
  7.  
  8. int i=0; // count
  9.  
  10. do{
  11. cout<<"Welcome!"<<endl;
  12. cout<<"1.Get the data"<<endl;
  13. cout<<"2.See the data"<<endl;
  14. cout<<" 1.forward"<<endl;
  15. cout<<" 2.backward"<<endl;
  16. cout<<"3.Add someone"<<endl;
  17. cout<<"4.Delete someone"<<endl;
  18. cout<<"5.Edit an entry"<<endl;
  19. cout<<"6.Search for someone"<<endl;
  20. cout<<" 1.ID"<<endl;
  21. cout<<" 2.last name"<<endl;
  22. cout<<"7.Sort the data"<<endl
  23. cout<<" 1.ID"<<endl;
  24. cout<<" 2.last name"<<endl;
  25. cout<<"8.Information about the file"<<endl;
  26. cout<<"9.Save"<<endl;
  27. cout<<"10.exit"<<endl;
  28.  
  29. cin>>choice;
  30. cout<<endl;
  31.  
  32. switch(choice)
  33. {
  34. case 1:
  35. {
  36. int id;
  37. string lastName, firstName, phone;
  38. double amt;
  39.  
  40. ifstream reader;
  41. reader.open("names.txt");
  42.  
  43. while(reader>>id>>lastName>>firstName>>phone>>amt)
  44. {
  45.  
  46. name[i].set(id, lastName, firstName, phone, amt);
  47. i++;
  48. }
  49. reader.close();
  50. cout<<"Data read."<<endl;
  51. break;
  52. }
  53. case 2:
  54. {
  55. int secPick;
  56. cout<<"1.forward 2.backward"<<endl;
  57. cin>>secPick;
  58. if(secPick==1)
  59. {
  60. showlist(name, i);
  61. cout<<endl;
  62. }
  63.  
  64. else if(secPick==2)
  65. {
  66. showlistBackward(name, i);
  67. cout<<endl;
  68. }
  69.  
  70. else
  71. {
  72. cout<<"You have entered a wrong option"<<endl;
  73. exit(1);
  74. }
  75. break;
  76. }
  77. case 3:
  78.  
  79. addName();
  80. break;
  81.  
  82. case 9:
  83. save(name, i);
  84. //cout<<"Sorry, not yet implemented.";
  85. break;
  86.  
  87. case 10:
  88. exit(0);
  89.  
  90. default:
  91. cout<<"Sorry, this input is not an option";
  92. exit(1);
  93.  
  94. }
  95. cout<<"Do you want to go back to the main menu? (Enter yes or no)";
  96. cin>>option;
  97. }while(option=="yes" || option=="Yes");
  98.  
  99. return 0;
  100. }
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,567
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 706
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: Assertion Failed

 
0
  #2
Jan 28th, 2008
>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.
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 1,810
Reputation: ithelp is a name known to all ithelp is a name known to all ithelp is a name known to all ithelp is a name known to all ithelp is a name known to all ithelp is a name known to all 
Solved Threads: 117
ithelp's Avatar
ithelp ithelp is offline Offline
Posting Virtuoso

Re: Assertion Failed

 
0
  #3
Jan 29th, 2008
Build your program in debug mode, and run in debug mode, you will find exact line which is causing assertion failure.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC