鱼C论坛

 找回密码
 立即注册
查看: 1541|回复: 18

[已解决]这个函数哪里错了

[复制链接]
发表于 2021-5-11 19:54:44 | 显示全部楼层 |阅读模式

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

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

x
本帖最后由 孤世星辰 于 2021-5-13 09:18 编辑


捕31获.PNG
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct Call
{
        char name[20];
        int phone[20];
        struct Call *next;
};

void getInput(struct Call *call);
void addPerson(struct Call **head);
struct Call *findPerson(struct Call *head);
void displayContacts(struct Call *head);
void printPerson(struct Call *call);
void changePerson(struct Call *head);
void delPerson(struct Call **head);
void getInput(struct Call *call)
{
        printf("请输入姓名:");
        scanf("%s",call->name);
        printf("请输入电话:");
        scanf("%d",call->phone);
}
void addPerson(struct Call **head)
{
        struct Call *call,*temp;
        static struct Call *tail;
        call=(struct Call *)malloc(sizeof(struct Call));
        if(call==NULL)
        {
                printf("内存分配失败!\n");
                exit(1);
        }
        getInput(call);
        if(*head!=NULL)
        {
                tail->next=call;
                call->next=NULL;
        }
        else
        {
                *head=call;
                call->next=NULL;
        }
        tail=call;
}
struct Call *findPerson(struct Call *head)
{
        struct Call *call;
        char input[128];
        call=head;
        printf("请输入要查找的姓名:");
        scanf("%s",input);
        while(call!=NULL)
        {
                if(!strcmp(call->name,input)||call!=NULL)
                {
                        break;
                }
                call=call->next;
        }
        return call;
}
void displayContacts(struct Call *head)
{
        struct Call *call;
        int count=1;
        while(call != NULL)
        {
                printf("第%d位联系人",count);
                printf("姓名:%s\n",call->name);
                printf("电话:%d\n",call->phone);
                call=call->next;
                count++;
        }
}
void printPerson(struct Call *call)
{
        printf("姓名:%s",call->name);
        printf("电话:%d",call->phone);
}
void changePerson(struct Call *head)
{
        struct Call *call;
        call=findPerson(head);
        if(call==NULL)
        {
                printf("找不到!\n");
        }
        else
        {
                printf("请输入新的号码:");
                scanf("%s",call->phone);
        }
}
void delPerson(struct Call **head)
{
        struct Call *call;
        struct Call *temp;
        struct Call *pre;
        struct Call *current;
        call=findPerson(*head);
        if(call==NULL)
        {
                printf("没找到!\n");
        }
        else
        {
                current=*head;
                pre=NULL;
                while(current!=NULL&¤t!=call)
                {
                        pre=current;
                        current=current->next;
                }
                if(pre==NULL)
                {
                        *head=current->next;
                }
                else
                {
                        pre->next=current->next;
                }
                free(call);
        }
}
void releaseContacts(struct Call **head)
{
        struct Call *temp;
        while(head!=NULL)
        {
                temp=*head;
                *head=(*head)->next;
                free(temp);
        }
}
main(void)
{
        struct Call *head=NULL;
        struct Call *call;
        int input;
        printf("| 欢迎使用通讯录管理程序 |\n");
        printf("|--- 1:插入新的联系人--- |\n");
        printf("|--- 2:查找新的联系人--- |\n");
        printf("|--- 3:更改新的联系人--- |\n");
        printf("|--- 4:删除新的联系人--- |\n");
        printf("|--- 5:显示新的联系人--- |\n");
        printf("|--- 6:退出新的联系人--- |\n");
        while(1)
        {
                printf("\n请输入代码指令:");
                scanf("%d",&input);
                switch(input)
                {
                        case 1:addPerson(&head); break;
                        case 2:findPerson(head);
                                if(call==NULL)
                                {
                                        printf("找不到!\n");
                               }
                                else
                                {
                                        printPerson(call);
                                }
                                break;
                        case 3:changePerson(head);break;
                        case 4:delPerson(&head);break;
                        case 5:displayContacts(head);break;
                        case 6:goto END;
                }
        }
END:
        releaseContacts(&head);

        return 0;
最佳答案
2021-5-13 11:11:55
你这个代码的问题也太多了吧,有认真检查代码吗
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct Call
{
    char name[20];
    int phone[20];
    struct Call *next;
};

void getInput(struct Call *call);
void addPerson(struct Call **head);
struct Call *findPerson(struct Call *head);
void displayContacts(struct Call *head);
void printPerson(struct Call *call);
void changePerson(struct Call *head);
void delPerson(struct Call **head);
void getInput(struct Call *call)
{
    printf("请输入姓名:");
    scanf("%s",call->name);
    printf("请输入电话:");
    scanf("%d",call->phone);
}
void addPerson(struct Call **head)
{
    //struct Call *call,*temp;
    struct Call *call;
    static struct Call *tail;
    call=(struct Call *)malloc(sizeof(struct Call));
    if(call==NULL)
    {
        printf("内存分配失败!\n");
        exit(1);
    }
    getInput(call);
    if(*head!=NULL)
    {
        tail->next=call;
        call->next=NULL;
    }
    else
    {
        *head=call;
        call->next=NULL;
    }
    tail=call;
}
struct Call *findPerson(struct Call *head)
{
    struct Call *call;
    char input[128];
    call=head;
    printf("请输入要查找的姓名:");
    scanf("%s",input);
    while(call!=NULL)
    {
        if(!strcmp(call->name,input)||call!=NULL)
        {
            break;
        }
        call=call->next;
    }
    return call;
}
void displayContacts(struct Call *head)
{
    //struct Call *call;
    struct Call *call = head;
    int count=1;
    while(call != NULL)
    {
        printf("第%d位联系人",count);
        printf("姓名:%s\n",call->name);
        //printf("电话:%d\n",call->phone);
        printf("电话:%d\n", *call->phone);
        call=call->next;
        count++;
    }
}
void printPerson(struct Call *call)
{
    printf("姓名:%s",call->name);
    //printf("电话:%d",call->phone);
    printf("电话:%d", *call->phone);
}
void changePerson(struct Call *head)
{
    struct Call *call;
    call=findPerson(head);
    if(call==NULL)
    {
        printf("找不到!\n");
    }
    else
    {
        printf("请输入新的号码:");
        //scanf("%s",call->phone);
        scanf("%d",call->phone);
    }
}
void delPerson(struct Call **head)
{
    struct Call *call;
    //struct Call *temp;
    struct Call *pre;
    struct Call *current;
    call=findPerson(*head);
    if(call==NULL)
    {
        printf("没找到!\n");
    }
    else
    {
        current=*head;
        pre=NULL;
        while(current!=NULL&¤t!=call)
        {
            pre=current;
            current=current->next;
        }
        if(pre==NULL)
        {
            *head=current->next;
        }
        else
        {
            pre->next=current->next;
        }
        free(call);
    }
}
void releaseContacts(struct Call **head)
{
    struct Call *temp;
    while(head!=NULL)
    {
        temp=*head;
        *head=(*head)->next;
        free(temp);
    }
}
//main(void)
int main(void)
{
    struct Call *head=NULL;
    struct Call *call;
    int input;
    printf("| 欢迎使用通讯录管理程序 |\n");
    printf("|--- 1:插入新的联系人--- |\n");
    printf("|--- 2:查找新的联系人--- |\n");
    printf("|--- 3:更改新的联系人--- |\n");
    printf("|--- 4:删除新的联系人--- |\n");
    printf("|--- 5:显示新的联系人--- |\n");
    printf("|--- 6:退出新的联系人--- |\n");
    while(1)
    {
        printf("\n请输入代码指令:");
        scanf("%d",&input);
        switch(input)
        {
            case 1:addPerson(&head); break;
            //case 2:findPerson(head);
            case 2: call = findPerson(head);
                   if(call==NULL)
                   {
                       printf("找不到!\n");
                   }
                   else
                   {
                       printPerson(call);
                   }
                   break;
            case 3:changePerson(head);break;
            case 4:delPerson(&head);break;
            case 5:displayContacts(head);break;
            case 6:goto END;
        }
    }
END:
    releaseContacts(&head);

    return 0;
}
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2021-5-12 10:00:32 | 显示全部楼层
代码整个发出来
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-5-12 11:20:04 | 显示全部楼层
你只贴一个代码片段,是肯定这段代码有问题?
就算是你肯定,问题是我们不知道 struct Call 这个结构体的内容
不知道这个数据结构的创建和销毁方法,简单来说就是不了解这个数据结构的物理布局和逻辑布局
如果要帮你解决问题,只有两种方法
1. 完全靠猜
2. 问你要完整的代码
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2021-5-13 09:18:37 | 显示全部楼层

发了发了,大佬给看一下
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2021-5-13 09:19:07 | 显示全部楼层
人造人 发表于 2021-5-12 11:20
你只贴一个代码片段,是肯定这段代码有问题?
就算是你肯定,问题是我们不知道 struct Call 这个结构体的 ...

错了错了,我发了
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-5-13 09:57:01 | 显示全部楼层
麻烦你把所有的变量初始化一遍
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2021-5-13 10:41:23 | 显示全部楼层
yuxijian2020 发表于 2021-5-13 09:57
麻烦你把所有的变量初始化一遍

捕111获.PNG
        struct Call *call=NULL;
        struct Call *temp=NULL;
        struct Call *pre=NULL;
        struct Call *current=NULL;
是这样么
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-5-13 11:11:55 | 显示全部楼层    本楼为最佳答案   
你这个代码的问题也太多了吧,有认真检查代码吗
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct Call
{
    char name[20];
    int phone[20];
    struct Call *next;
};

void getInput(struct Call *call);
void addPerson(struct Call **head);
struct Call *findPerson(struct Call *head);
void displayContacts(struct Call *head);
void printPerson(struct Call *call);
void changePerson(struct Call *head);
void delPerson(struct Call **head);
void getInput(struct Call *call)
{
    printf("请输入姓名:");
    scanf("%s",call->name);
    printf("请输入电话:");
    scanf("%d",call->phone);
}
void addPerson(struct Call **head)
{
    //struct Call *call,*temp;
    struct Call *call;
    static struct Call *tail;
    call=(struct Call *)malloc(sizeof(struct Call));
    if(call==NULL)
    {
        printf("内存分配失败!\n");
        exit(1);
    }
    getInput(call);
    if(*head!=NULL)
    {
        tail->next=call;
        call->next=NULL;
    }
    else
    {
        *head=call;
        call->next=NULL;
    }
    tail=call;
}
struct Call *findPerson(struct Call *head)
{
    struct Call *call;
    char input[128];
    call=head;
    printf("请输入要查找的姓名:");
    scanf("%s",input);
    while(call!=NULL)
    {
        if(!strcmp(call->name,input)||call!=NULL)
        {
            break;
        }
        call=call->next;
    }
    return call;
}
void displayContacts(struct Call *head)
{
    //struct Call *call;
    struct Call *call = head;
    int count=1;
    while(call != NULL)
    {
        printf("第%d位联系人",count);
        printf("姓名:%s\n",call->name);
        //printf("电话:%d\n",call->phone);
        printf("电话:%d\n", *call->phone);
        call=call->next;
        count++;
    }
}
void printPerson(struct Call *call)
{
    printf("姓名:%s",call->name);
    //printf("电话:%d",call->phone);
    printf("电话:%d", *call->phone);
}
void changePerson(struct Call *head)
{
    struct Call *call;
    call=findPerson(head);
    if(call==NULL)
    {
        printf("找不到!\n");
    }
    else
    {
        printf("请输入新的号码:");
        //scanf("%s",call->phone);
        scanf("%d",call->phone);
    }
}
void delPerson(struct Call **head)
{
    struct Call *call;
    //struct Call *temp;
    struct Call *pre;
    struct Call *current;
    call=findPerson(*head);
    if(call==NULL)
    {
        printf("没找到!\n");
    }
    else
    {
        current=*head;
        pre=NULL;
        while(current!=NULL&¤t!=call)
        {
            pre=current;
            current=current->next;
        }
        if(pre==NULL)
        {
            *head=current->next;
        }
        else
        {
            pre->next=current->next;
        }
        free(call);
    }
}
void releaseContacts(struct Call **head)
{
    struct Call *temp;
    while(head!=NULL)
    {
        temp=*head;
        *head=(*head)->next;
        free(temp);
    }
}
//main(void)
int main(void)
{
    struct Call *head=NULL;
    struct Call *call;
    int input;
    printf("| 欢迎使用通讯录管理程序 |\n");
    printf("|--- 1:插入新的联系人--- |\n");
    printf("|--- 2:查找新的联系人--- |\n");
    printf("|--- 3:更改新的联系人--- |\n");
    printf("|--- 4:删除新的联系人--- |\n");
    printf("|--- 5:显示新的联系人--- |\n");
    printf("|--- 6:退出新的联系人--- |\n");
    while(1)
    {
        printf("\n请输入代码指令:");
        scanf("%d",&input);
        switch(input)
        {
            case 1:addPerson(&head); break;
            //case 2:findPerson(head);
            case 2: call = findPerson(head);
                   if(call==NULL)
                   {
                       printf("找不到!\n");
                   }
                   else
                   {
                       printPerson(call);
                   }
                   break;
            case 3:changePerson(head);break;
            case 4:delPerson(&head);break;
            case 5:displayContacts(head);break;
            case 6:goto END;
        }
    }
END:
    releaseContacts(&head);

    return 0;
}
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2021-5-13 12:50:35 | 显示全部楼层
本帖最后由 孤世星辰 于 2021-5-13 12:52 编辑
人造人 发表于 2021-5-13 11:11
你这个代码的问题也太多了吧,有认真检查代码吗


其实我对这个程序也不是理解的特别深刻,我有好多问题都一知半解,大佬可以帮我解释一下么,真的超级感谢
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct Call
{
    char name[20];
    int phone[20];
    struct Call *next;
};

void getInput(struct Call *call);
void addPerson(struct Call **head);
struct Call *findPerson(struct Call *head);
void displayContacts(struct Call *head);
void printPerson(struct Call *call);
void changePerson(struct Call *head);
void delPerson(struct Call **head);

void getInput(struct Call *call)
{
    printf("请输入姓名:");
    scanf("%s",call->name);
    printf("请输入电话:");
    scanf("%d",call->phone);
}
void addPerson(struct Call **head)           //这里传来的是head的地址,所以这里**是代表head指针的指针么,但是我没有定义过这个指针啊,系统自己就会有么
                                                            //还有就是这里不是只要修改head指针就好了么,为什么要传入head指针的指针,像我们平时改一个变量不是让a=1就好了么,不应该只要改head指针就好了嘛
{
    //struct Call *call,*temp;
    struct Call *call;
    static struct Call *tail;
    call=(struct Call *)malloc(sizeof(struct Call));
    if(call==NULL)
    {
        printf("内存分配失败!\n");
        exit(1);
    }
    getInput(call);
    if(*head!=NULL)
    {
        tail->next=call;                                        
        call->next=NULL;
    }
    else
    {
        *head=call;                                           //这个是head指针指向call,意思是结构体跟数组一样是地址么
        call->next=NULL;
    }
    tail=call;
}
struct Call *findPerson(struct Call *head)          //这里find前面为啥要加*,是因为要返回结构体指针么?
{
    struct Call *call;
    char input[128];
    call=head;
    printf("请输入要查找的姓名:");
    scanf("%s",input);
    while(call!=NULL)
    {
        if(!strcmp(call->name,input)||call!=NULL)
        {
            break;
        }
        call=call->next;
    }
    return call;
}
void displayContacts(struct Call *head)
{
    //struct Call *call;
    struct Call *call = head;
    int count=1;
    while(call != NULL)
    {
        printf("第%d位联系人",count);
        printf("姓名:%s\n",call->name);
        //printf("电话:%d\n",call->phone);
        printf("电话:%d\n", *call->phone);
        call=call->next;
        count++;
    }
}
void printPerson(struct Call *call)
{
    printf("姓名:%s",call->name);
    //printf("电话:%d",call->phone);
    printf("电话:%d", *call->phone);
}
void changePerson(struct Call *head)
{
    struct Call *call;
    call=findPerson(head);
    if(call==NULL)
    {
        printf("找不到!\n");
    }
    else
    {
        printf("请输入新的号码:");
        //scanf("%s",call->phone);
        scanf("%d",call->phone);
    }
}
void delPerson(struct Call **head)
{
    struct Call *call;
    //struct Call *temp;
    struct Call *pre;
    struct Call *current;
    call=findPerson(*head);                        //这里应该是传入head么
    if(call==NULL)
    {
        printf("没找到!\n");
    }
    else
    {
        current=*head;                                //为啥不是*current=*head,这样把head指针给current指针,到底是*current代表指针还是current代表指针?搞不懂这两个区别
        pre=NULL;
        while(current!=NULL&¤t!=call)
        {
            pre=current;
            current=current->next;
        }
        if(pre==NULL)
        {
            *head=current->next;
        }
        else
        {
            pre->next=current->next;
        }
        free(call);
    }
}
void releaseContacts(struct Call **head)
{
    struct Call *temp;
    while(head!=NULL)
    {
        temp=*head;
        *head=(*head)->next;
        free(temp);
    }
}
//main(void)
int main(void)
{
    struct Call *head=NULL;
    struct Call *call;
    int input;
    printf("| 欢迎使用通讯录管理程序 |\n");
    printf("|--- 1:插入新的联系人--- |\n");
    printf("|--- 2:查找新的联系人--- |\n");
    printf("|--- 3:更改新的联系人--- |\n");
    printf("|--- 4:删除新的联系人--- |\n");
    printf("|--- 5:显示新的联系人--- |\n");
    printf("|--- 6:退出新的联系人--- |\n");
    while(1)
    {
        printf("\n请输入代码指令:");
        scanf("%d",&input);
        switch(input)
        {
            case 1:addPerson(&head); break;
            //case 2:findPerson(head);
            case 2: call = findPerson(head);          //这边不是返回了call么为什么又要call=find()?是因为局部变量?
                   if(call==NULL)
                   {
                       printf("找不到!\n");
                   }
                   else
                   {
                       printPerson(call);
                   }
                   break;
            case 3:changePerson(head);break;
            case 4:delPerson(&head);break;
            case 5:displayContacts(head);break;
            case 6:goto END;
        }
    }
END:
    releaseContacts(&head);

    return 0;
}
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-5-13 13:43:02 | 显示全部楼层
孤世星辰 发表于 2021-5-13 12:50
其实我对这个程序也不是理解的特别深刻,我有好多问题都一知半解,大佬可以帮我解释一下么,真的超级感 ...
void addPerson(struct Call **head)           //这里传来的是head的地址,所以这里**是代表head指针的指针么,但是我没有定义过这个指针啊,系统自己就会有么
                                                            //还有就是这里不是只要修改head指针就好了么,为什么要传入head指针的指针,像我们平时改一个变量不是让a=1就好了么,不应该只要改head指针就好了嘛
要修改这个指针的值,就需要这个指针的地址,就是指向指针的指针,二级指针

 *head=call;                                           //这个是head指针指向call,意思是结构体跟数组一样是地址么
是改变调用这个函数的时候传入的那个变量的值
在这里是改变main函数中第149行的那个head变量的值,因为165行调用addPerson这个函数的时候把head的地址作为参数(&head)
149行的head是一个指针
就是改变这个指针变量中保存的值,就是改变这个指针的指向


struct Call *findPerson(struct Call *head)          //这里find前面为啥要加*,是因为要返回结构体指针么?
对

call=findPerson(*head);                        //这里应该是传入head么
不行,因为findPerson这个函数要求一个struct Call *head,是个一级指针,而delPerson这个函数的head是一个二级指针


current=*head;                                //为啥不是*current=*head,这样把head指针给current指针,到底是*current代表指针还是current代表指针?搞不懂这两个区别
*current是对这个指针解引用,current是一个一级指针,而且没有让这个指针指向一个有效的对象,不能对current解引用
current=*head; *head就是main函数中第149行的那个head变量中的内容,这是让current这个指针和main函数中149行的那个head指向同一个对象

 case 2: call = findPerson(head);          //这边不是返回了call么为什么又要call=find()?是因为局部变量?
不明白你的问题,这个是让call指向findPerson函数返回的那个对象

评分

参与人数 1荣誉 +5 鱼币 +5 贡献 +3 收起 理由
孤世星辰 + 5 + 5 + 3

查看全部评分

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2021-5-13 14:18:08 | 显示全部楼层

哦哦哦谢谢,我终于理顺了,最后那个问题就是find函数最后不是return call了么
那么我直接
find(head)
if(call==NULL)这样判断不可以么
为什么还要
call=find(head)
if(call==NULL)
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-5-13 14:35:37 | 显示全部楼层
孤世星辰 发表于 2021-5-13 14:18
哦哦哦谢谢,我终于理顺了,最后那个问题就是find函数最后不是return call了么
那么我直接
find(head ...

你没有为变量call赋值呀,把返回值赋值给call

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2021-5-13 14:42:11 | 显示全部楼层
人造人 发表于 2021-5-13 14:35
你没有为变量call赋值呀,把返回值赋值给call


哦哦哦好的吧,那我记住了,但是我的运行功能不对诶,是我编译器的问题么
捕54获.PNG
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-5-13 15:40:50 | 显示全部楼层
孤世星辰 发表于 2021-5-13 14:42
哦哦哦好的吧,那我记住了,但是我的运行功能不对诶,是我编译器的问题么

提示让你输入指令,你输入 “蠢才”干嘛
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2021-5-13 17:25:22 | 显示全部楼层
人造人 发表于 2021-5-13 15:40
提示让你输入指令,你输入 “蠢才”干嘛

啊这,还是不对呢
122捕获.PNG
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-5-13 19:20:08 | 显示全部楼层
void releaseContacts(struct Call **head)
{
    struct Call *temp;
    //while(head!=NULL)
    while(*head!=NULL)
    {
        temp=*head;
        *head=(*head)->next;
        free(temp);
    }
}
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2021-5-14 09:44:11 | 显示全部楼层
本帖最后由 孤世星辰 于 2021-5-14 09:47 编辑


还有一个问题是为啥我输入‘蠢才’,但是他给我找到的永远是第一个联系人呢?
        if(!strcmp(call->name,input)||call!=NULL)
是这个有问题么
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-5-14 09:52:37 | 显示全部楼层
孤世星辰 发表于 2021-5-14 09:44
还有一个问题是为啥我输入‘蠢才’,但是他给我找到的永远是第一个联系人呢?

是这个有问题么

是不等于还是等于?
if(!strcmp(call->name,input)||call == NULL)
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2021-5-14 10:16:15 | 显示全部楼层
人造人 发表于 2021-5-14 09:52
是不等于还是等于?
if(!strcmp(call->name,input)||call == NULL)

嗯嗯这回好了,谢谢
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-9-21 08:50

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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