Write a program that reads a name from the text file name.txt
.
If the file does not exist,
your program should print name.txt: file not found
to standard output.
If the file does exist,
your program should print the first word found in the file.
Either way,
for this exercise specifically
your program should terminate with an exit code of 0
– exit(0)
or return 0
from main
.
Here is an example command line session:
$ ls
file-read
$ ./file-read
name.txt: file not found
$ echo Mary > name.txt
$ ./file-read
Mary
The name given in the test input is no longer than 60 characters
and may be followed by a line break in the name.txt
file.
Depending on the language you are using
you may have to strip any trailing line break
after reading from the name.txt
file.
try first: file-write
try next: run-count
Copyright © 2020-2023 Rudy Matela
All rights reserved