whats wrong in using gets...
whats wrong in using gets...
-
You have no control with gets() over the number of chars read. This leads to buffer overrun errors. Someone said here, "so what, I'll just make the buffer bigger".To which the reply was doing that doesn't remove the bug,it just lessens its probability of occurring.Anytime that you need to use gets() you can use fgets() instead to get a certain number of chars from stdin and then you will never encounter the buffer overrun possibility.
Free the weed!! Class B to class C is not good enough!!
And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi
thanks guys. i have another question:
else if(answer==2)
{
cout<<"Define locationdiskdrive:\\folder\\filename) : ";
cin>>location;
strcat(location,".txt");
write.open(location,ios:ut);
bla bla bla
}
this actually works well, but if the user keys in a location which does not have a folder he keyed, then the file won't be saved.
such as, c:\hello\hello where by "hello" folder doesn't exit on his harddrive
so how can we solve this problem??