How to count all the words in a textfile with multiple space characters
问题 I am trying to write a procedure that counts all the words in a text file in Pascal. I want it to handle multiple space characters, but I have no idea how to do it. I tried adding a boolean function Space to determine whether a character is a space and then do while not eof(file) do begin read(file,char); words:=words+1; if Space(char) then while Space(char) do words:=words; but that doesnt work, and basically just sums up my(probably bad) idea about how the procedure should look like. Any