简体   繁体   中英

Is there a way to access the next line with getline() with c++?

I am trying to access the next line to check if I would like to change a variable or not. Specifically, I want to check if the difference between the current value and the next one is less than a number, if it is not than I would like to assign a different value to a variable, but if it its than I want to retain the value I have now. My question is, is there a way to "look ahead" with getline(), kind of like an equivalent of i+1 in a for loop.

I suggest to defer acting on the first line until the second is parsed.

Then you can decide whether to use a content from the first line or modify it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM