Im trying to get a string from the user without using scanf. Im using gets() right now but the compiler gives me a warning:
/tmp/cchB57W8.o(.text+0x419): the `gets' function is dangerous and should not be used.
Is there alternatives to gets()?
Im trying to get a string from the user without using scanf. Im using gets() right now but the compiler gives me a warning:
/tmp/cchB57W8.o(.text+0x419): the `gets' function is dangerous and should not be used.
Is there alternatives to gets()?
FAQ > Explanations of... > Why gets() is bad / Buffer Overflows
FAQ > How do I... (Level 1) > Get a line of text from the user/keyboard (C)
7. It is easier to write an incorrect program than understand a correct one.
40. There are two ways to write error-free programs; only the third one works.*
Now that's a nice compiler. Make sure you read the links Dave fave you. They'll help you understand the problem and give you some other side information you need, but the main thing you need to take away: use fgets() and specify stdin as the file pointer.Im using gets() right now but the compiler gives me a warning:
If you want to get a line of user input of inderminate length, go to the topic
"Reading indeterminate length line from file."
makes you wonder why that function is still around. the ANSI boys should phase it out of the libraries.
>the ANSI boys should phase it out of the libraries.
It would break too much existing code, and that goes against the goals of the ISO committee. Sadly, we're stuck with gets, but we do a nice job of squelching it wherever it pops up.
My best code is written with the delete key.