Keep in mind that strlen() will only work if your string has a null character at the end. In the case of scanf, it should be null terminated as long as the user doesn't input more than 19 characters. (more than that and the program could crash or just act strangely of course.)
quote:
Originally posted by RaceProUK
quote:
Originally posted by Chancer
code:
char word[20];
scanf ("%s", word);
Bye-bye program
Not always. Depending on how much data is inputed in to the program, and how much other data is on the stack, it could just overwrite the other variables in the function. Even if the data size does exceed the current stack frame, there's always going to be a chance that the return address is going to be overwritten by a random, but valid memory address, which would cause a very interesting situation to debug.