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,而在我的main中,我希望得到我的变量string str1, string str2, int num 得到输入数据。所以用户输入后,str1 = string1, str2 = string2, num = 123。我会用cin来读取数据,但是如何一个一个地读取呢?谢谢!
假设字符串中没有空格,您可以简单地提取它们:
cin >> str1 >> str2 >> num;