- #1
Hiche
- 84
- 0
Homework Statement
Write a program that takes a file name as argument and counts the number of words and the number of characters (without spaces) in the document.
Homework Equations
The Attempt at a Solution
How exactly should my program take a .txt file as an argument? Do I simply:
Code:
String str = args[0];
And the contents of the .txt file are stored as strings? (The file is a text file with only letters).
And how to check for each word inside that file? Let it read the string till encountering a space then (by previously declaring a count variable) increment count? I'm confused here. Is it that same as just studying a string?
Last edited: