Hi,
I'm new with C programming and I would like to know the code that would allow me to enter numbers like 987654321 and put each of them in an array [0] --> 9, [1]-->8...
do
{ puts("Enter your nine number ");
gets(number);
AnalyseNumber //where I want my array with my numbers
Thanks



LinkBack URL
About LinkBacks



If you know what could go wrong, you can use it safely. If you don't know what could go wrong, you can still get away with using it in throw away programs.
It only takes one parameter, the array to put a string into, but the array has a finite size and gets() has no way of telling what that size is. So gets() assumes that the array is big enough and just copies everything it gets even if the array isn't big enough. That's called buffer overrun, and it can be used by hackers to circumvent the security on a computer and break into it.
It's just that easy. Not really as evil as you were led to believe, huh?
It's perfectly safe if you control the input and can guarantee that it all fits in the array. The only difference is that gets() is "evil" so you make an exception.