为什么函数引用不了,函数运行结果错误

void shanchu()
{

int num_chazhao(int numc);
int name_chazhao(char namec[20]);
char namec[20];
char shuru;
int i,location,numc;
int a;
while(1)
{
printf("请选择删除对象的查询方式,并输入相应序号:\n1.编号 2.名称\n");
scanf("%d",&a);
if (a==1)
{
printf("请输入编号:\n");
scanf("%d",&numc);
location=num_chazhao(numc);
}
else
{
printf("请输入名称:\n");
scanf("%s",&namec[20]);
location=name_chazhao(namec);
}
if (location=-1)
{
printf("药品不存在!\n");
}
else
{
printf("即将删除的药品信息为:\n");
bufenliulan(location);
printf("是否删除?是(Y),否(N)\n");
scanf("%s",&shuru);
if (shuru=='Y')
for (i=location;i<N-1;i++)
{
med[i]=med[i+1];
}
else
break;
}
}
}
int num_chazhao(int numc)
{
int i;
for(i=0;i<N;i++)
{
if(numc==med[i].num)
{
return(i);
break;
}
}
return(-1);
}
int name_chazhao(char namec[20])
{
int i;
for(i=0;i<N;i++)
{
if(strcmp(med[i].name,namec)==0)
{
return(i);
}
}
return(-1);
}

2个回答

// Q764134.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define N 5

struct Medicine
{
    int num;
    char name[20];
};

Medicine med[N];

void bufenliulan(int location)
{

}

void shanchu()
{
    int num_chazhao(int numc);
    int name_chazhao(char namec[20]);
    char namec[20];
    char shuru;
    int i, location, numc;
    int a;
    while (1)
    {
        printf("请选择删除对象的查询方式,并输入相应序号:\n1.编号 2.名称\n");
        scanf("%d", &a);
        if (a == 1)
        {
            printf("请输入编号:\n");
            scanf("%d", &numc);
            location = num_chazhao(numc);
        }
        else
        {
            printf("请输入名称:\n");
            scanf("%s", &namec[20]);
            location = name_chazhao(namec);
        }
        if (location == -1)
        {
            printf("药品不存在!\n");
        }
        else
        {
            printf("即将删除的药品信息为:\n");
            bufenliulan(location);
            printf("是否删除?是(Y),否(N)\n");
            scanf("%c", &shuru);
            if (shuru == 'Y')
                for (i = location; i < N - 1; i++)
                {
                    med[i] = med[i + 1];
                }
            else
                break;
        }
    }
}
int num_chazhao(int numc)
{
    int i;
    for (i = 0; i < N; i++)
    {
        if (numc == med[i].num)
        {
            return(i);
            break;
        }
    }
    return(-1);
}
int name_chazhao(char namec[20])
{
    int i;
    for (i = 0; i < N; i++)
    {
        if (strcmp(med[i].name, namec) == 0)
        {
            return(i);
        }
    }
    return(-1);
}

int main()
{

}

void shanchu()
{
int num_chazhao(int numc);
int name_chazhao(char namec[20]);
char namec[20];
char shuru;
int i,location,numc;
int a;
while(1)
{
printf("请选择删除对象的查询方式,并输入相应序号:\n1.编号 2.名称\n");
scanf("%d",&a);
if (a==1)
{
printf("请输入编号:\n");
scanf("%d",&numc);
location=num_chazhao(numc);
}
else
{
printf("请输入名称:\n");
scanf("%s",&namec[20]);
location=name_chazhao(namec);
}
if (location=-1)
{
printf("药品不存在!\n");
}
else
{
printf("即将删除的药品信息为:\n");
bufenliulan(location);
printf("是否删除:是(Y),否(N)\n");
scanf("%s",&shuru);
if (shuru=='Y')
for (i=location;i<N-1;i++)
{
med[i]=med[i+1];
}
else
break;
}
}
}
int num_chazhao(int numc)
{
int i;
for(i=0;i<N;i++)
{
if(numc==med[i].num)
{
return(i);
break;
}
}
return(-1);
}
int name_chazhao(char namec[20])
{
int i;
for(i=0;i<N;i++)
{
if(strcmp(med[i].name,namec)==0)
{
return(i);
}
}
return(-1);
}

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐