hello goodbye see ya
please enter a file name> test.txt hello goodbye see ya
please enter a file name> test.txt hello goodbye see ya number of lines: 3To check that your program works you can compare its output to the wc command.
% wc test.txt 3 4 21 test.txt ^ ^ ^ number of lines number of words number of bytes (chars)Note: the wc command counts the number of '\n's in the file as the number of lines. When you create a text file in vi, vi automatically adds a '\n' before the EOF. When you create a text file in emacs, emacs does not automatically add a '\n' before EOF. As a result, if the text.txt file above is created in emacs, wc will return 2 as number of lines, if created in vi, it will return 3. Your program should return 3 for the line count for text.txt no matter if the file has the '\n' before EOF or not (no matter if it was created by vi or emacs).