![]() |
|
#1
|
|||
|
|||
Find common words between the two filesHello, everyone!
Can anyone help me with this? 2 files are read and I must write a C++ program which has to show me all the common words between the two files. How can I do it? This is what I tried, but... CPP / C++ / C Code:
Last edited by admin : 13-Dec-2008 at 12:55.
Reason: Please insert your example C/C++ codes between [CPP] and [/CPP] tags
|
|||
|
#2
|
|||
|
|||
Re: Please help meI know that I can use strcmp( ), but I don't know how to write it.. Please help me! thank you
|
|
#3
|
|||
|
|||
Re: Find common words between the two filesThere is much outdated with your code (i.e. you should #include <iostream> instead of <iostream.h>, main return int, not void, etc). However, if this is to be C++ why not just use the std::string class? Couple that with a std::map (possibly, std::map < std::string, int >) and you can do something like (this is pseudocode)
CPP / C++ / C Code:
Note: Handling punctuation becomes more difficult, but the iostream/string classes have utilities for such things. __________________
My personal site: Utilities for text processing, debugging, testing and plotting |
|
#4
|
||||
|
||||
Re: Find common words between the two filesQuote:
...particularly when dealing with words containing apostrophes, such as isn't, wouldn't, shouldn't, etc. versus 'single' 'quoted' words. princess The requirements lack detailed information as to what "common" means. For example, is "Name" and "name" common enough? If that's true, what about "Bob" a pronoun and "bob" a verb? What about when "bob" the verb is the first word in a sentence and is therefore capitalized? Is it the same word as Bob the pronoun? Without a detailed definition of commonality, we can only assume that equality delineates commonality among words. Is that the objective of the application? Is that information specified in the requirements? If not, seek requirements elucidation before proceeding. strtok is inherently unsafe. If you mean to use C and not C++, use it. If you mean to use C++, use std::string. Bob the 'can |
|
#5
|
|||
|
|||
Re: Find common words between the two filesI didn't study any std::string class, std::map. It doesn't amtter if the world is a verb, a pronoun or whatever. OHH.....What can I do? How can I know the common words??? How to find them? give me a hit, something!
|
Recent GIDBlog
Accepted for Ph.D. program by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The