|
藍森林 http://www.lslnet.com 2006年6月6日 10:18
5555錯的我莫名其妙
幫我看看吧,我也不知道為什麼錯。
int main()
{
char *name;
struct passwd *pt;
printf("Input the login_name:");
scanf("%s",&name);
if ((pt=getpwnam(name))==NULL)
printf("Sorry,invalid name\n");
else
printf("Found\n");
}
我輸入我的登錄名字,結果出來「Memory fault--core dumped".
怎麼了?為什麼又core dumped了? |
5555錯的我莫名其妙
char *name 並沒有分配實際的地址,怎麼可能把名字scanf進來呢?? |
5555錯的我莫名其妙
:wink: 我知道了。呵呵。 |
| |