#include <stdio.h>
#include <string.h>
#define max 501
void start()
{
printf("当前通讯录最大容纳人数:%d。\n如需修改请修改源文件。\n",max-1);
}
struct tel
{
char name[10];
char num[20];
};
void input(struct tel *pttel1,int *counter)
{
int i,cmem1=0;
printf("请输入想创建的联系人人数:\n");
scanf("%d",&cmem1);
getchar();
for(i=0;i<cmem1;i++)
{
printf("新建联系人姓名:\n");
gets(pttel1->name);
printf("新建联系人电话:\n");
gets(pttel1->num);
}
counter+=cmem1;
}
void search(struct tel *pttel1,struct tel tel1)
{
int i,j,k,cmem2=0;
char name1[10];
printf("请输入想查找的联系人个数:\n");
scanf("%d",&cmem2);
getchar();
for(i=0;i<cmem2;i++)
{
printf("需查找的联系人姓名:\n");
gets(name1);
for(*pttel1=tel1;pttel1<&tel1+max;pttel1++)
{
if(strcmp(name1,pttel1->name)==0)
printf("您所查找的联系人为:%s\n其电话号码为%s\n",pttel1->name,pttel1->num);break;
}
printf("您查找的联系人不存在。\n通讯录中的联系人为:\n");
for(*pttel1=tel1;pttel1<&tel1+max;pttel1++)
printf("%s:%s\n",pttel1->name,pttel1->num);
}
}
int main()
{
start();
int choice,*counter,sum=0;
counter=∑
struct tel tel1[max];
struct tel *pttel1;
pttel1=tel1;
spawnpoint:printf("创建联系人输入\"1\",查找联系人输入\"2\",退出输入\"0\"。\n");
scanf("%d",&choice);
if(choice==1)
input(pttel1,counter);
else if(choice==2)
search(pttel1,tel1);
else if(choice==0)
return 0;
else
printf("错误\n");
goto spawnpoint;
}
求问哪写错了
编译器DevC++5.11
C:\Users\xbw\Desktop\未命名3.c In function 'main':
63 6 C:\Users\xbw\Desktop\未命名3.c [Error] incompatible type for argument 2 of 'search'
29 6 C:\Users\xbw\Desktop\未命名3.c [Note] expected 'struct tel' but argument is of type 'struct tel *'
C语言程序,问哪写错了。
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
1条回答 默认 最新
- 不易七 2021-12-04 17:20关注
tel1的类型是struct tel*,但是你search函数中参数2需要的是struct tel
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 BP神经网络控制倒立摆
- ¥20 要这个数学建模编程的代码 并且能完整允许出来结果 完整的过程和数据的结果
- ¥15 html5+css和javascript有人可以帮吗?图片要怎么插入代码里面啊
- ¥30 Unity接入微信SDK 无法开启摄像头
- ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
- ¥20 cad图纸,chx-3六轴码垛机器人
- ¥15 移动摄像头专网需要解vlan
- ¥20 access多表提取相同字段数据并合并
- ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
- ¥20 Java-Oj-桌布的计算