Here's the pseudocode for word counting:
function countWords(filename)
infile := open file(filename)
for reading
if infile failed to open then
print "Error: cannot open file"
return -1 count := 0
word := empty string
while infile >> word succeeds do
count := count + 1 close infile
return count result := countWords("input.txt")
if result >= 0 then
print "Word count: " + result
``` In C++, use #include <fstream> for file streams.