![]() |
| ||
| Compare a string with a file. Hi, I'm quite new to C++ so all help is appreciated. I have a program that makes a string of at least three characters. I want to be able to compare the string to a list of words (i.e. dictionary) in a separate file, and then output the string if it is in the dictionary. The string 'word' is a string object so I'm having problems with strcmp (which only takes chars?). The reason I used a string object is because I have to use substr and concatenation, and I'm not very familiar with using char arrays. (I've mostly done Java before). What I have got so far: char dictword[32]; Thanks in advance, Tim |
| ||
| Re: Compare a string with a file. Quote:
string word = "abc";Off course you'll have to build in some error checking etc. And this code assumes that all words in textfile are delimited with a space. So some more work is required from you |
| All times are GMT -4. The time now is 3:23 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC