What did we just read from the file?
Our call to the fgets() function
will have read in all characters on each line of the dictionary but,
if we're interested in processing the characters as simple strings,
we find that we've got "too much".
Each line read will actually have:
The character '\n',
the familiar newline character often used in print(),
is silently added to text lines by our text editors.
In fact on Windows' machines,
text files also include a carriage-return character before
the newline character.
As we know,
we can simply turn this into a more manageable string
by replacing the newline or carriage-return character by the
null-byte.
CITS2002 Systems Programming, Lecture 7, p6, 12th August 2024.
|