Retrieving Values from a Text Document

Hello. I need to write a program that will retrieve numerical values from a text document.

Say the values are 5, 7, 12, 41, and 2

In the text document, do I write verbatim, "5, 7, 12, 41, 2"?

Really all I have experience with is the <iostream>, and the <cmath> libraries.

I then need the program to say which of the values is the minimum value.

How do I do this? Thanks so much!!! (grateful to the wonderful forum community)
http://www.cplusplus.com/doc/tutorial/files/
Reading from a file is the same as reading from cin
The easiest file format to read is values separated by spaces
Wonderful? Wonderful?! How dare you call us a wonderful community you stuck-up complementary excuse for a dork! Just kidding. Thanks. :)

Jokes aside, if (given an array/vector/deque/list of values) you need to find a smallest value, what you can do is store the first value of your array in a variable which will hold your smallest value. Then, you can check each value in order and determine whether it is smaller or not than your variable, and if it is reassign your variable to that number (loop recommended).

Good luck!

-Albatross
Last edited on
Topic archived. No new replies allowed.