Skip to content

Conversation

@skcshubham
Copy link
Contributor

@skcshubham skcshubham commented Oct 7, 2019

This is the code to check whether string is anagram or not.
Anagram is a word, phrase, or name formed by rearranging the letters of another, such as spar, formed from rasp.

This is he code to check whether string is anagram.
Anagram is a word, phrase, or name formed by rearranging the letters of another, such as spar, formed from rasp.
@skcshubham skcshubham changed the title Anagram-Program-in-C checkAnagram.c Oct 7, 2019
@gouravthakur39
Copy link
Owner

@skcshubham The `gets' function is dangerous and should not be used. Use fgets instead.
An explanation from stack overflow :

Why is gets() dangerous
The first internet worm (the Morris Internet Worm) escaped about 30 years ago (1988-11-02), and it used gets() and a buffer overflow as one of its methods of propagating from system to system. The basic problem is that the function doesn't know how big the buffer is, so it continues reading until it finds a newline or encounters EOF, and may overflow the bounds of the buffer it was given.

You should forget you ever heard that gets() existed.

The C11 standard ISO/IEC 9899:2011 eliminated gets() as a standard function, which is A Good Thing™ (it was formally marked as 'obsolescent' and 'deprecated' in ISO/IEC 9899:1999/Cor.3:2007 — Technical Corrigendum 3 for C99, and then removed in C11). Sadly, it will remain in libraries for many years (meaning 'decades') for reasons of backward compatibility.

fgets() added to the program instead of gets() function. The code runs without breaking and has proper comments. Thanks!
@gouravthakur39 gouravthakur39 merged commit c7be60d into gouravthakur39:master Oct 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants