如何使用户输入多行字符串数据在c ++? [英] How to make user input multiline string data in c++?

查看:326
本文介绍了如何使用户输入多行字符串数据在c ++?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试过getline(cin,....),但这不能接受输入多于一行。输入结束由类似#。

I tried getline(cin, .... ), but this cannot take input more than one line. The end of input is determined by something like #.

推荐答案

决定。你可以使用不同于'\\\
'

You can use getline with a different character than '\n' as the delimeter.

// will collect input until the user enters a #
getline(cin,mystring,'#');

这篇关于如何使用户输入多行字符串数据在c ++?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆