日期:2014-05-16  浏览次数:20736 次

我的sprintf有错误,不知道什么问题。
char *sqlstr=NULL;
sprintf(sqlstr,"select * from %s where name='%s' and password='%s'","fwusers","uname","passwd");
编译没有问题,运行显示段错误。
请问哪里出了问题。

------解决方案--------------------
char *sqlstr=NULL; 这一句也太可怕了吧,你竟然要对一个NULL去赋值。。
sprintf(sqlstr,"select * from %s where name='%s' and password='%s'","fwusers","uname","passwd"); 
随便改个
char sqlstr[1024]; 
sprintf(sqlstr,"select * from %s where name='%s' and password='%s'","fwusers","uname","passwd");