DVH> char name[40];
DVH> gets(name);
DVH> name[40]='\0';
TT> That still leaves the problem that you're writing to memory that
TT> isn't yours. Your array is only 40 characters long and you try to
TT> access the 41st element!
DVH> Actually it is correct. I don't know where you
DVH> see anything wrong, but
DVH> I have been making programs with that method for a while.
DVH> Here is how I thought of it:
It is not correct, and the fact that you have done this for a while is
irrelevant. The array name is 40 characters long. These are accessed 0-39.
When you write a 0 to name[40], you are writing to memory you don't own and
it will blow up one day.
Bruce
--- Maximus/2 3.01
---------------
* Origin: COMM Port OS/2 juge.com 204.89.247.1 (281) 980-9671 (1:106/2000)
|