|
Writing to a FileTo write to a file, use the write function. This function takes a string as its parameter, and writes the string to its associated output file. For example, here is a simple program that opens a file for writing, and then writes two strings to the file:
Note that this program writes the two strings to the same output line. The output file looks like this:
To write the strings on separate lines, add a newline character, represented by \n, to the end of the first string:
|