Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
ユーザーは次のように入力します: string1 string2 123。私のメインでは、変数 string str1、string str2、int num を取得して入力データを取得したいと考えています。したがって、ユーザー入力の後、str1 = string1、str2 = string2、num = 123 になります。データを読み取るために cin を使用しますが、それらを 1 つずつ読み取る方法は? ありがとうございました!
文字列にスペースがないと仮定すると、単純に抽出できます。
cin >> str1 >> str2 >> num;