http://blog.csdn.net/liwei_cmg/archive/2006/05/29/759963.aspx 不过会有告警提示: /tmp/ccC7E6qe.o(.text+0xea): In function `db_connect': /home/ora/develop/src/db.c:385: the `gets' function is dangerous and should not be used.
这个是由于使用了gets函数所致,见gets的man手册:
BUGS Never use gets(). Because it is impossible to tell without knowing the data in advance how many characters gets() will read, and because gets() will continue to store characters past the end of the buffer, it is extremely dangerous to use. It has been used to break computer security. Use fgets() instead.
It is not advisable to mix calls to input functions from the stdio library with low - level calls to read() for the file descriptor asso-ciated with the input stream; the results will be undefined and very probably not what you want.