index | submit | rank | book

file-write – Writing to files

Write a program that:

  1. creates a text file called message.txt with a single line containing a “Hello file system.” message on it;
  2. writes the line “Created text file message.txt” to the standard output.

Here is an example command line session:

$ ./file-write
created text file message.txt
$ cat message.txt
Hello file system.



If your program is working correctly, you should be able to open the message.txt file in your text editor of choice: gedit, nano, vi, notepad, etc. You should see the written message on it.

On Linux systems you can use cat message.txt to the the contents of the message.txt file from the command line. On Windows system you can use type message.txt.

try first: hello

try next: file-read

index | submit | rank | book

Copyright © 2020-2021 Rudy Matela
All rights reserved