如何在C ++中识别换行? [英] How to identify a new line in C++?

查看:77
本文介绍了如何在C ++中识别换行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须将整数输入到整数数组.我还必须在输入中标识换行符.更清楚地说,我有一个例子.我给的输入是:-

I have to take integer input to an integer array. I have to identify the newline also in input. To be more clear, I have an example. The input I am giving is:-

2
3
4

45
6
78
45

34
34

我想根据输入中的换行符处理输入.

I want to process the input according to the newline in the input.

编程语言是C ++,编译器是g ++.我不想将换行符存储在数组中;我只想进行相应处理.

The programming language is C++ and the compiler is g++. I don't want to store the newline in the array; I just want to process accordingly.

推荐答案

您可以使用< string>中的std :: getline.读取整行并使用< sstream>中的std :: stringstream解析线条.

You can use std::getline from <string> to read whole lines and use a std::stringstream, from <sstream> to parse the lines.

这篇关于如何在C ++中识别换行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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