0

Hi everyone,
I have a simple setback in my program. I'm not the best way to go about doing this. I'm trying to do it in the simplest way possible. I have an input file that looks like this

2.5 600 -2
10 20 30

I want to sort each line using my own sort algorithm, but I want to work on one line at a time, storing the numbers in a vector. I think one solution is to use getline and put it into a strstream and maybe extract the values one at a time from the stream. This way I can separate it by lines. The problem is I want to IN the float values, so I don't know how to test for a newline if I'm using something (psuedo-code) like cin >> int x Any ideas?

2
Contributors
1
Reply
2
Views
10 Years
Discussion Span
Last Post by WolfPack
0

I think one solution is to use getline and put it into a strstream and maybe extract the values one at a time from the stream. This way I can separate it by lines.

Yes that is the best way to do it

The problem is I want to IN the float values, so I don't know how to test for a newline if I'm using something (psuedo-code) like cin >> int x Any ideas?

Why do you want to test for a newline?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.