Any trick for calculate the number words in the text file?

01/07/2004 - 14:28 por Frank | Informe spam
for some reason, i have to write some code to calculate the number of words
which exists in the text file. the language of text is international. but,
at above of them, i wanna write some code to figure the western language
out. but, i really cannt get any trick or idea for it. so, i wrote this post
to ask for some helps. any reply is appreciated :-)

Frank F.Han

+--+
| winsays@:-)hotmail:-).com |
+--+
 

Leer las respuestas

#1 TVR Fan
01/07/2004 - 16:03 | Informe spam
"Frank" wrote in message
news:%23$
for some reason, i have to write some code to calculate the number of


words
which exists in the text file. the language of text is international. but,
at above of them, i wanna write some code to figure the western language
out. but, i really cannt get any trick or idea for it. so, i wrote this


post
to ask for some helps. any reply is appreciated :-)



I don't really understand what you are asking in terms of languages. If you
are trying to ascertain the language from the text, I suppose you could
search for joining words: if the file contains lots of 'the', 'and', 'then',
'to' etc then it's English. 'le', 'la', 'en' etc indicate French and so on.

Do you have to write your own program to counting words? Linux & Unix
systems have a command 'wc' which gives a word count for a given file. I'm
sure you can download a Windows version of the same. MS Word has a Word
Count option under the Tools menu.

If you really do need to do it in code, two ways spring to mind:
you could use the system() C library function to run the wc command and
redirect its output to a file?
Or do the counting yourself: open a CFile object, read each line and use
strchr() to loop though the line looking for space characters.

Either way, I don't think this is really an MFC question is it?

Al.

Preguntas similares