藍森林首頁 | 返回主頁 | 本站地圖 | 站內搜索 | 聯繫信箱 |
 您目前的位置:首頁 > 自由軟件 > 技術交流 > 應用編程


    

藍森林 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: 我知道了。呵呵。



Copyright © 1999-2000 LSLNET.COM. All rights reserved. 藍森林網站 版權所有。 E-mail : webmaster@lslnet.com