Originally Posted by
PepiMK
gets is evil
No buffer length checking, typical C problem leading to buffer overflows = security holes or at least crashes.
fgets might be the nearest replacement. Unless you need to use C and not C++, I would probably use
cin/
cout.
Btw, why do you mix
puts/
gets and
scanf/
printf? Why not stick with the later for the text as well, with checking its return value of course and specifying the length (buffer minus 1!)?
Anythings better than
gets I know that doesn't answer your problem, but I had to say it
First thank you for yur reply PepiiMK. But actually I couldn't understand what you meant at the 2.paragraph, so I can't answer your question, sorry
It looks like using scanf and gets together causes some problems. I have overcomed of the problem by adding this code:
Code:
printf("Please enter the name of the dvd: %s");
while(i<3){
a=gets(dvd[serial].name);
if(i==1 && a[0]==0);
else if(i==2&&a[0]==0)
break;
i++;
}