鱼C论坛

 找回密码
 立即注册
查看: 1384|回复: 3

[已解决]C语言的一个报错嘻嘻

[复制链接]
发表于 2018-7-20 02:38:07 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. struct Tt
  5. {
  6.    char xingm[20];
  7.    char dianhua[20];
  8.    struct Tt *next;
  9. };

  10. void addperson(struct Tt **star);
  11. void addperson(struct Tt **star)
  12. {
  13.     struct Tt *neww=NULL;

  14.     struct Tt *aft;

  15.     struct Tt *same;

  16.     struct Tt *bf;


  17.     aft=*star; same=aft; bf = NULL;
  18.     neww = (struct Tt *)malloc(sizeof(struct Tt));
  19.     if(neww==NULL){printf("内存分配失败\n");}
  20.     printf("请输入录入联系人姓名和电话(姓名空格电话):");
  21.     scanf("%s %s",neww->xingm,neww->dianhua);




  22.     while( same!=NULL && !strcmp(same->xingm,neww->xingm)    )
  23.     {
  24.         bf = same;
  25.         same=same->next;
  26.     }

  27. }

  28. int main()
  29. {
  30.     struct Tt *star=NULL;

  31.     while(1)
  32.     {
  33.         addperson(&star);
  34.     }

  35.     return 0;
  36. }
复制代码


这个是编译器提示内容
The program being debugged was signaled while in a function called from GDB.
GDB has restored the context to what it was before the call.
To change this behavior use "set unwindonsignal off".
Evaluation of the expression containing the function
(strcmp) will be abandoned.
Program received signal SIGSEGV, Segmentation fault.
0x77956680 in strcmp () from C:\WINDOWS\SYSTEM32\ntdll.dll


所以请老师,或者人造人老师看看。   

代码先不管它要达到什么效果,要出现这个提示,需要把 !strcmp(same->xingm,neww->xingm) 复制到调试窗口中才可以触发,  为什么会出现这样的提示呢?

阿里旺旺图片20180720023729.jpg
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2018-7-21 18:11:34 | 显示全部楼层
你用的是dev-cpp
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2018-7-21 18:15:26 | 显示全部楼层    本楼为最佳答案   
GIF.gif
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2018-7-23 17:56:15 | 显示全部楼层
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-4-26 13:41

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表