C++を利用して
英語で名前をコンソールから入力し
英語のイニシャルを出力するプログラムを作成しています。
下記のように作成してうまくいったのですが
以下の2点、お伺いできますと幸いです。
1,cin.ignore()の使い方を教えていただけると幸いです。。
(どういった使い方をして引数には何を指定すべきなのでしょうか)
2,<istream>はどういったライブラリなのでしょうか。
3、今回のプログラムで<istream>と<iomanip>は必要でしょうか。
上記の解答をグーグルで検索等してみたのですが
よくわからなかったので教えてくださいますと幸いです。
#include <iostream> #include <string> #include <istream> //#include <iomanip> using namespace std; int main(void) { char firstInitial; char lastInitial; cout<< "Enter your first and last name:"; firstInitial = cin.get(); cin.ignore(256 , ' '); lastInitial=cin.get(); cout << firstInitial<<lastInitial; return 0; } 実行結果 Enter your first and last name :Harry Truman HT
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。