/*-------
Signature: main: void -> int
Purpose: to read each "word" in the file
looky.txt in the current directory,
and print it on its own line
("word" here means any consecutive
non-white-space characters
separated by white space)
Examples: if looky.txt is empty,
running this program does nothing.
if looky.txt happens to contain:
Now is the time
for all good Doges
to come to the aid of their bacon!
then this will print to the screen:
Now
is
the
time
for
all
good
Doges
to
come
to
the
aid
of
their
bacon!
by: Sharon Tuttle
last modified: 2016-12-06
--------*/
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <fstream>
using namespace std;
int main()
{
cout << boolalpha;
string input_file = "looky.txt";
// create an input stream and connect
// it to looky.txt
ifstream in_stream;
in_stream.open(input_file.c_str());
if (in_stream.fail())
{
cout << "there is NO file looky.txt!"
<< endl;
return EXIT_FAILURE;
}
string next_word;
in_stream >> next_word;
while (in_stream.eof() == false)
{
cout << next_word << endl;
in_stream >> next_word;
}
// close your input stream when done
in_stream.close();
return EXIT_SUCCESS;
}