c++ Segmentation fault when taking int input from user in terminal but not xcode -


i having issues reading in file xcode decided switch terminal test it, in terminal getting segmentation fault when following function executes (only when choosing 1). ideas?

turns out problem reading file in. going post question handling that.

struct system { character player; }; struct character { string name; ushort money; ushort intelligence; ushort time; ushort steps; ushort score; };  bool get_number ( int& number ) { while ( !( cin >> number ) ) {     if ( cin.eof() )         return false;     else {         char ch;         cin.clear();         cout<<"invalid input, please try again: ";         while (cin.get(ch) && ch != '\n' );     } } return true; }  void viewmenu(menu menuchoice) { cout << menuchoice.options; cout << "\nplease choose option: "; int number; get_number(number); if (menuchoice.choice == 0) {     if (number == 1) {         struct system game;         startgame(playername);     }     else if (number == 2) {         viewscores(gamescoreboard);         viewmenu(startmenu);     }     else {         cout << "goodbye";         exit(0);     } } 

again, works fine in xcode, in terminal fails when choosing "1".


Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -