C++에서 문자를 입력 받기 위해
string strId;
cin >> strId;
명령을 사용하면 띄어쓰기로 구분된 문장을 입력 받지 못한다.(아래 예시)
#include <iostream> #include <string> using namespace std; int main () { string strId; cout << "ID를 입력 해주세요. " << endl; cin >> strId; cout << "Hello " << strId << "!" << endl; return 0; }
아래와 같이 getline(cin, strId);
와 같이 getline을 사용하여 문장을 입력 받는다.
#include <iostream> #include <string> using namespace std; int main () { string strId; cout << "ID를 입력 해주세요. " << endl; getline (cin, strId); cout << "Hello " << strId << "!" << endl; return 0; }
Güncel ve en iyi yabancı filmleri yüksek görüntü kalitesinde, Türkçe dublaj ve altyazı seçenekleriyle filmleri full izleyin. (2024) Jessie Schnair
What’s Taking place i am new to this, I stumbled upon this I’ve discovered It absolutely helpful and it has aided me out loads. I’m hoping to give a contribution & assist other customers like its aided me. Great job.
You made some clear points there. I did a search on the subject and found most individuals will approve with your site.