lucky_therock wrote:
hey..i ma newbie to c programming...its just my 3rd program..so i
wanna know a code in which input string can be matched with strings in
another opened file....!!
So, what do you have so far?
- Determine your specifications (exact string match? partial matches?
find all matches or first one wins?)
- Sketch out some pseudo-code to work out your algorithm.
- Iteratively develop the code.
e.g., my naive approach:
- Process the args verbatim (spaces significant), converting to same
case (caring about locale) if we don't care about case and make this our
constant search string. Handle errors.
- Open the external file, and read in contents as text, forming what we
get as an array of strings (convert to same case [again, locale issues]
if necessary). Handle error on open, on read and on memory allocation(s).
- Iterate through the strings, matching with our search string. On a
match, do something (save something or set a flag or whatever). Repeat
until list exhausted, if necessary.
The devil is in the details, but the actual logic is pretty simple. Of
course, there is all sorts of room for improvement on what I've
described here.
--
clvrmnky
Direct replies will be blacklisted. Replace "spamtrap" with my name to
contact me directly.