Hey,
I have to write a code,which reads a file and finds anagrams in it.The output is a set of anagrams(the output I am getting from this code) again to be printed in a text file.
Can you please tell me how can I delete the repeated anagram sets from the output of your code and also how to write the output to a file.
If I am trying to write output to a file it is printing some random characters.:(
Also it would be a great help if you could xplain your logic to me.
Thanks

Recommended Answers

All 4 Replies

Well, first of all you should study how to print a string into a file, life fprintf or fputs. Second, explain yourself: You mean you have a file like this:
pplea
Which becomes
apple
OR like this
rtyeppleasfg
and becomes
apple, leaf, fags, please
What do you mean by "find anagrams in it"?

Thanks for the references.
There is a file which contains word like, act,cat,tap, rat, pat, tar, etc etc so i need to find the words which are anagram of each other.
My output should be like:cat act
tap pat etc etc
also(if no anagram are found such words need not b printed)
What is happening with my o/p is that it is redundant
cat act
tap pat
cat act
ie: if cat is encountered act is its anagram annd if act is encountered again cat act are printed whereas i want it to be printed only once.
I want the o/p to be in a file.

Maybe... You could copy all the text in an array and then delete the part you've already written?
Or Maybe... Your loop has an error in the while (statement)?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.