掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
数値でなければ〜はどうすれば? (ID:69424)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
改善しました ただ、↓に書いてあるようにループから抜け出した後終了してしまいます どうすればいいのでしょうか /* if x was not a number, show please enter the number */ cout << "enter the number for x (only integer, though!!): "; while(1){ cin >> x; bool cin_err = cin.fail (); if( cin_err ==0 ) break; cin.clear (); cin.ignore (100, '\n'); cout << "enter the number again, not an alphabet."; } return x; /* serious problem going on... pushing ENTER key after cout << "enter the number again, not an alphbet."; is making this program stop. I can't find why. */ cout << "enter the number for y (only integer, though!!): "; cin >> y;
←解決時は質問者本人がここをチェックしてください。
更新する
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.