Write a program that counts lines in input.txt. Open an ifstream, use getline() in a loop, and increment a counter for each line. Print the total when done. Test with empty files (0 lines), single-line files, and multi-line files.
Your program should handle all cases without crashing. Check if the file opened before counting. Extend this to count words (using >> word) or characters (using get()). These patterns form the basis of text analysis tools like wc on Unix systems.