How is 'string' defined for this purpose? Technically any text file only has one string, the entire contents of the file. Another common method is reading words where a 'word' is any unbroken sequence of non-whitespace characters.
Exactly. A 'string' can be
- a single word
- a single line
- a sentence
- a paragraph
- a page
- entire file
Be explicit...
WaltP
Posting Sage w/ dash of thyme
10,505 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
Well you can use a counter variable and every time you read a string increment the counter by 1.
NathanOliver
Veteran Poster
1,084 posts since Apr 2009
Reputation Points: 215
Solved Threads: 189
@ adityatandon if you include a check for a space and a \n then you will get the right amount of words.
NathanOliver
Veteran Poster
1,084 posts since Apr 2009
Reputation Points: 215
Solved Threads: 189
adityatandon, what part of
Sorry! The strings in question are single lines of no more than 30 characters.
did you not understand?
WaltP
Posting Sage w/ dash of thyme
10,505 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944