given a text file containing multiple words like CS50, Add, work, etc. does each of these words end with '\n', or both, '\0' and '\n'?

1 Answer 1


a text file is a stream of individual characters, not strings. the way you read/store a group of these chars, from the file, totally depends on you.

for example, you may wanna read collectively or one by one. you may wanna and store them in a char array (not terminated with '\0') or a string (terminated with '\0'). you may wanna interpret them differently or cast/convert them to other datatypes.

also there is no enforced structure on how text files should be written. you may have a text file with one line (i.e., ends with a '\n') or multiple lines (i.e., has multiple '\n's), or no lines at all (i.e., doesn't have '\n').

in the context of English, if a text file has a bunch of English words that form sentences, syntactically, a word is the sequence of chars that have whitespace (including newline) on either side.

in case of speller, you may assume, per the specs, that the dictionary file is structured in such a way that you have a word per line.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .