Program that reads a list

The practice prompt is as follows:
Write a program that reads the list /users/calendow/assignments/shortest-word and prints out the single shortest word in it.

Here is what I have so far:

#include<iostream>
#include<fstream>
using namespace std;

int main()
{
ifstream inputFile("/users/calendow/assignments/shortest-word");

return 0;
}

So my first guess is to open the file to find the shortest word. It would probably be best if I follow the path to open the file and see what the list contains. How do I do that?

Secondly where do I go from here? I am completely lost. Any help is appreciated.

Thank you in advance.
After you have opened the file you can read the first word and store it in a variable. After that you read word after word and compare it to the shortest word so far. If it is shorter you set it as the shortest word. Then you can close the file and print the shortest word.
If you need any help in dealing with files have a look at this tutorial.
http://www.cplusplus.com/doc/tutorial/files/
I opened the file and it contains a list of over a 1000 words. So I have to go thru and look for the shortest word?
Yes I am afraid there is no other way - unless the list is sorted what I can't imagine because it would spoil the whole exercise.
Topic archived. No new replies allowed.