马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct Tt
{
char xingm[20];
char dianhua[20];
struct Tt *next;
};
void addperson(struct Tt **star);
void addperson(struct Tt **star)
{
struct Tt *neww=NULL;
struct Tt *aft;
struct Tt *same;
struct Tt *bf;
aft=*star; same=aft; bf = NULL;
neww = (struct Tt *)malloc(sizeof(struct Tt));
if(neww==NULL){printf("内存分配失败\n");}
printf("请输入录入联系人姓名和电话(姓名空格电话):");
scanf("%s %s",neww->xingm,neww->dianhua);
while( same!=NULL && !strcmp(same->xingm,neww->xingm) )
{
bf = same;
same=same->next;
}
}
int main()
{
struct Tt *star=NULL;
while(1)
{
addperson(&star);
}
return 0;
}
这个是编译器提示内容
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) 复制到调试窗口中才可以触发, 为什么会出现这样的提示呢?
|