fstream and .csv files

Pages: 12
I think the trick here is to realise that entry1 contains the current state when you do your magnitude check. So all you need to do is keep a note of the state alongside the maximum magnitude and your home free.
		if (int_magnitude > max_magnitude)
			max_magnitude = int_magnitude;
			max_state = entry1; // remember the state from the line you found the max magnitude

Because you only record the state when you find a new max_magnitude, you know at the end it will be the state from the same line as the maximum magnitude.

You will have to declare max_state (or whatever you call it) in the same place you declare max_magnitude.
Last edited on
Galik, thank you so much once again. I understand now. Since the magnitude check is nested in the while loop, which goes through each line, entry1 should be on the same line as the max_magnitude if noted in the same if() statement. Actually, I think you explained it much better, haha!
You have been an enormous help to me and probably other people who have been keeping up with this thread. I thank you for taking the time to help. You have given me a boost in confidence and have encouraged me to continue on my C++ journey. Thank you!
Topic archived. No new replies allowed.
Pages: 12