Please send questions to
st10@humboldt.edu .
/*-----
contract: write_to_looky: string -> void
purpose: expects a string, and returns nothing,
but it has the side-effect of writing that
string to the file in the current working
directory named looky.txt (nuking whatever
previous contents it had)
examples:
If I call:
write_to_looky("Hi there! Lookit me!!");
...this should have the side effect of causing the
file in the current directory named looky.txt to
contain:
Hi there! Lookit me!!
by: Sharon Tuttle
last modified: 5-3-10
-----*/
#include <fstream>
#include <string>
using namespace std;
void write_to_looky(string msg)
{
// create an output file stream
ofstream outstream;
// open it for writing, to a file named looky.txt
outstream.open("looky.txt");
// write the desired message to that file using outstream
// (I'm choosing to add a newline to the end of the message)
outstream << msg << endl;
// close the output file stream when you're done
outstream.close();
}