| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 782 人关注过本帖
标题:帮忙解释下function' : 'const char *' differs in levels of indirection ...
取消只看楼主 加入收藏
lamb512
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2023-4-5
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:1 
帮忙解释下function' : 'const char *' differs in levels of indirection from 'int '
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<conio.h>
#include <windows.h>
#define n 1000
void Append();//录入
void menu();//菜单
void Browse();//浏览
void Endprogram();//退出
void Findin();//查询
int validateID(int _id);//编号查重
int key();//员工验证
void userkey();//用户身份验证
void welcome();//员工登录界面
int allkey();//登录界面
int menu1();//用户界面
void Browse1();//用户查询
int member();// 会员信息
int modify();//修改物品
void cut();//物品删除
int logon();
struct ima
{
    int id;
    char name[20];
    char produce[30];
    int number;
    int price;
};
struct post
{
    char id[20];
    char key[20];
};
void cut()
{
    FILE *fp;
    struct ima bride[1000];
    int i=0;
    int j;
    int input_id;
    char choice;
    fp=fopen("goods","r");
    if(fp==NULL)
    {
        printf("系统出错,请重试.......");
        exit(0);
    }
    for(;!feof(fp);i++)
    {
        fread(&bride[i],sizeof(struct ima),1,fp);
    }
    fclose(fp);
    printf("请输入删除物品编号:");
    scanf("%d",&input_id);
    fopen("goods","w");
    for(j=0;j<i-1;j++)
    {
        if(input_id==bride[j].id)
        {
            printf("移出成功\n");
        }
        if(input_id!=bride[j].id)
        {
            fwrite(&bride[j],sizeof(struct ima),1,fp);
        }
    }
    fclose(fp);
    printf("\n您想继续吗?(y/n)");
    scanf(" %c",&choice);
    if(choice=='Y'||choice=='y')
    {
        cut();
    }
    else
    {
        system("cls");
        menu();
    }
}

int modify()//修改物品
{   
    FILE *fp;   
    int choice;   
    struct ima b[n];
    struct ima a;
    int i=0;
    int c=0;
    int j;
    int z=0;
    system("cls");
    fp=fopen("goods","r");
    if(fp==NULL)
    {
        printf("系统出错,请重试......");
        exit(0);
    }
    fread(&a,sizeof(struct ima),1,fp);
    while(!feof(fp))
    {
        b[i]=a;
        i++;
        fread(&a,sizeof(struct ima),1,fp);   
    }   
    fclose(fp);
    printf("输入修改编号");
    scanf("%d",&c);
    j=c-1;//数组下标
    printf("-------------------------\n");
        getchar();
        printf("输入商品名字");
        gets(b[j].name);
        printf("输入商品数量");
        scanf("%d",&b[j].number);
        getchar();
        printf("输入商品价格");
        scanf("%d",&b[j].price);
        getchar();
        printf("输入商品地址");
        gets(b[j].produce);
        printf("-------------------------\n");
    fp=fopen("goods","w");
    if(fp==NULL)
    {
        printf("系统出错,请重试......");
        exit(0);
    }
    while(z<i)
    {
        a=b[z];
        fwrite(&a,sizeof(struct ima),1,fp);
        z++;
    }
    printf("录入成功\n");
    fclose(fp);
    printf("完成修改\n");
    printf("是否继续修改\n");
    printf("1.是 2.否\n");
    scanf("%d",&choice);
    if(choice==1)
    {
        modify();
    }
    else if(choice==2)
    {
        menu();
    }
    return 0;
}
int member()//会员信息
{
    printf("系统维护\n");
    return 0;
}
int allkey()//登入界面
{   
    int choice;
    system("cls");
printf("                -------------------------------------------\n");
    printf("                ∞∞∞∞∞∞∞∞ 1.员工登录∞∞∞∞∞∞∞∞\n");
    printf("                ∞∞∞∞∞∞∞∞ 2.用户登录∞∞∞∞∞∞∞∞\n");
    printf("                ∞∞∞∞∞∞∞∞ 3.用户注册∞∞∞∞∞∞∞∞\n");   
printf("                -------------------------------------------\n");
printf("               请输入登入编号:");
scanf("%d",&choice);
    if(choice==1)
    key();
    else if(choice==2)
    userkey();
    else if(choice==3)
    logon();
    return 0;
}
int logon()//注册账户
{
    struct post bridge;
    FILE *fp;
    fp=fopen("key","ab");
    if(fp==NULL)
    {
        printf("系统错误,请重试.........");
        exit(0);
    }
    getchar();
    printf("请输入注册账户\n");
    gets(bridge.id);
    printf("请输入注册密码\n");
    gets(bridge.key);
    fwrite(&bridge,sizeof(struct post),1,fp);
    fclose(fp);
    printf("注册成功\n");
    Sleep(500);
    allkey();
    return 0;
}
int key()//员工密码检测
{
    char ke[7]="aaaaaa";
    char get_ke[7];
        printf("               请输入密码:");
        getchar();
        gets(get_ke);
        if(strcmp(ke,get_ke)==0)
        {
            printf("密码正确\n");
            Sleep(500);
            menu();
        }
        else
        {
            printf("密码错误\n");
        }

    return 0;
}
void userkey()
{
    char choice;
    FILE *fp;
    struct post get_key;
    struct post bridge;   
    printf("请输入ID\n");
    getchar();
    gets(get_key.id);
    printf("请输入密码\n");
    gets(get_key.key);
    fp=fopen("key","r");
    if(fp==NULL)
{
    printf("系统错误,请重试......");
    exit(0);
}
    fread(&bridge,sizeof(struct post),1,fp);
    while(!feof(fp))
{
    if(strcmp(get_key.id,bridge.id==0))
    {
        if(strcmp(get_key.key,bridge.key)==0)
            {
                printf("密码正确\n");
                fclose(fp);
                Sleep(500);
                menu();
            }
        else
            {
                printf("密码错误");
                fclose(fp);
                key();
            }
    }
    fread(&bridge,sizeof(struct post),1,fp);
}
    printf("账户不存在,请注册账号");
    printf("\n是否注册账号?(y/n)");
    scanf(" %c",&choice);
    if(choice=='Y'||choice=='y')
    {
        logon();
    }
    else
    {
        system("cls");
        welcome();
    }

}
int validateID(int _id)//编号查重
{
   
    FILE *fp;
    struct ima v;
    fp=fopen("GOODS","r");
    if(fp==NULL)
    {
        printf("\t\t\t系统错误,请您重试........");
        exit(0);
    }
   
    fread(&v,sizeof(struct ima),1,fp);
    while(!feof(fp))
    {
        if(v.id==_id)
        {
            fclose(fp);
            return 1;
            break;
        }
        fread(&v,sizeof(struct ima),1,fp);
    }
    fclose(fp);
    return 0;
        
}
void Findin()
{
    struct ima f;
    int find_id;
    char choice;
    FILE *fp;
    fp=fopen("GOODS","r");
    if(fp==NULL)
    {
        printf("\t\t\t系统错误,请您重试........");
        exit(0);
    }
Flag:
    printf("请输入查询编号:");
    scanf("%d",&find_id);
    fread(&f,sizeof(struct ima),1,fp);
    while(!feof(fp))
    {
        if(f.id==find_id)
        {
            printf("\n\n\t***************物品信息******************");
            printf("\n\t物品编号...%30d\n",f.id);
            printf("\n\t-----------------------------------------");
            printf("\n\t物品名称...%30s\n",f.name);
            printf("\n\t-----------------------------------------");
            printf("\n\t生产厂家...%30s\n",f.produce);
            printf("\n\t-----------------------------------------");
            printf("\n\t进口数量...%30d\n",f.number);
            printf("\n\t-----------------------------------------");
            printf("\n\t批发价格...%30.3d\n",f.price);
            printf("\n\t-----------------------------------------");
            printf("\n您想继续吗?(y/n)");
            scanf(" %c",&choice);
            if(choice=='Y'||choice=='y')
            {
                Findin();
            }
            else
            {
                system("cls");
                menu();
            }
            
        }
        fread(&f,sizeof(struct ima),1,fp);
    }
    fclose(fp);
    printf("此编号不存在,请重新输入:");
    goto Flag;


}

void Append()//录入
{
    struct ima a;
    char choice;
    FILE *fp;
    fp=fopen("GOODS","ab");
    if(fp==NULL)
    {
        printf("\t\t\t系统错误,请您重试........");
        exit(0);
    }
labID:
    printf("\n\t请您输入要入库物品的信息...\n");
    printf("\t\t\t\t   物品的编号:");
    scanf("%d",&a.id);
    if(validateID(a.id)==1)
    {
        printf("\t\t\t\t此编号已被使用,请您重新输入......");
        goto labID;
    }
    printf("\t\t\t\t   物品的名称:");
    scanf("%s",a.name);
    printf("\t\t\t\t   物品的生产地:");
    scanf("%s",a.produce);
    printf("\t\t\t\t   物品的数量:");
    scanf("%d",&a.number);
    printf("\t\t\t\t   物品的单价:");
    scanf("%d",&a.price);
    fwrite(&a,sizeof(struct ima),1,fp);

    fclose(fp);
    printf("\t\t\t\t\t\t  物品信息已入库成功!!!\n");
    printf("\n您想继续吗?(y/n)");
    scanf(" %c",&choice);
    if(choice=='Y'||choice=='y')
    {
        Append();
    }
    else
    {
        system("cls");
        menu();
    }
   
}
void Browse1()//用户浏览
{
    struct ima b;
    int index=0;
    char choice;
    FILE *fp;
    fp=fopen("GOODS","r");
    if(fp==NULL)
    {
        printf("\t\t\t系统错误,请您重试........");
        exit(0);
    }
    fread(&b,sizeof(struct ima),1,fp);
    while(!feof(fp))
    {
        index++;
        printf("\n\n\t****************物品信息%d*****************",index);
        printf("\n\t物品编号...%30d\n",b.id);
        printf("\n\t-----------------------------------------");
        printf("\n\t物品名称...%30s\n",b.name);
        printf("\n\t-----------------------------------------");
        printf("\n\t生产厂家...%30s\n",b.produce);
        printf("\n\t-----------------------------------------");
        printf("\n\t进口数量...%30d\n",b.number);
        printf("\n\t-----------------------------------------");
        printf("\n\t批发价格...%30d\n",b.price);
        printf("\n\t-----------------------------------------");
        getch();
        fread(&b,sizeof(struct ima),1,fp);
    }
    fclose(fp);
    printf("\n您想继续吗?(y/n)");
    scanf(" %c",&choice);
    if(choice=='Y'||choice=='y')
    {
        Browse1();
    }
    else
    {
        system("cls");
        menu1();
    }

}
void Browse()//浏览
{
    struct ima b;
    int index=0;
    char choice;
    FILE *fp;
    fp=fopen("GOODS","r");
    if(fp==NULL)
    {
        printf("\t\t\t系统错误,请您重试........");
        exit(0);
    }
    fread(&b,sizeof(struct ima),1,fp);
    while(!feof(fp))
    {
        index++;
        printf("\n\n\t****************物品信息%d*****************",index);
        printf("\n\t物品编号...%30d\n",b.id);
        printf("\n\t-----------------------------------------");
        printf("\n\t物品名称...%30s\n",b.name);
        printf("\n\t-----------------------------------------");
        printf("\n\t生产厂家...%30s\n",b.produce);
        printf("\n\t-----------------------------------------");
        printf("\n\t进口数量...%30d\n",b.number);
        printf("\n\t-----------------------------------------");
        printf("\n\t批发价格...%30d\n",b.price);
        printf("\n\t-----------------------------------------");
        getch();
        fread(&b,sizeof(struct ima),1,fp);
    }
    fclose(fp);
    printf("\n您想继续吗?(y/n)");
    scanf(" %c",&choice);
    if(choice=='Y'||choice=='y')
    {
        Browse();
    }
    else
    {
        system("cls");
        menu();
    }

}
int menu1()//用户
{
    int choice;
        system("cls");
        printf("-------------------------\n");
        printf("欢迎使用xxx超市系统\n");
        printf("1.会员信息查询\n");
        printf("2.查询商品信息\n");
        printf("3.退出\n");
        printf("-------------------------\n");
        scanf("%d",&choice);
        switch(choice)
        {
        case 1:
            member();
            break;
        case 2:
            Browse1();
            break;
        case 3:
            allkey();
            break;
        }
        return 0;
}
void Endprogram()//退出
{
    char choice;
    system("cls");
   
    printf("\n\n\n\n\n\n\n\t\t\t您确定要退出系统吗?\n\n\n\t\t\t如果您想退出请按'y',其它键将返回主菜单.....");
    scanf(" %c",&choice);
    if(choice=='Y'||choice=='y')
    {
        system("cls");
        printf("\n\n\n\n\n\n\n\n\n\n\t\t\t\t谢谢您的使用!!!");
        printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
    }
    else
    {
        system("cls");
        menu();
    }
}
void menu()//菜单
{   
    int choice;
    system("cls");
    printf("\n∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞【超市库存管理系统】∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞\n");
    printf("--------------------------------系统菜单显示如下--------------------------------");
    printf("\n\t1=====================【           新购物品入库         】\n");
    printf("\n\t2=====================【           物品信息浏览         】\n");
    printf("\n\t3=====================【           物品信息查询         】\n");
    printf("\n\t4=====================【           物品信息修改         】\n");
    printf("\n\t5=====================【           物品信息删除         】\n");
    printf("\n\t6=====================【           退出         】\n");
    printf("\n\t请输入您要选择的菜单......");
    scanf("%d",&choice);
    switch(choice)
    {
    case 1:
        Append();
        break;
    case 2:
        Browse();
        break;
    case 3:
        Findin();
        break;
    case 4:
        modify();
        break;
    case 5:
        cut();
        break;
    case 6:
        Endprogram();
        break;
    default:
        printf("\n\t\t\t\t\t输入无效,请您重新输入......");
        getch();
        system("cls");
        menu();
    }
}
void welcome()
{
    printf("\n\n");
    //system("color 1a");
    printf("\t\3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3\n");
    printf("\t\3                                                               \3\n");
    printf("\t\3                                                               \3\n");
    printf("\t\3                        欢迎使用                               \3\n");
    printf("\t\3                                                               \3\n");
    printf("\t\3                                                               \3\n");
    printf("\t\3                     超市库存管理系统                          \3\n");
    printf("\t\3                      按任意键继续                             \3\n");
    printf("\t\3                                                               \3\n");
    printf("\t\3                                                               \3\n");
    printf("\t\3                                                               \3\n");
    printf("\t\3                                                               \3\n");
    printf("\t\3                                                               \3\n");
    printf("\t\3                                                               \3\n");
    printf("\t\3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3");
    getch();
    system("cls");
     allkey();
}
int main()
{
     welcome();
}
搜索更多相关主题的帖子: scanf int printf struct choice 
2023-04-05 19:42
lamb512
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2023-4-5
收藏
得分:0 
报错在红色处
2023-04-05 19:44
快速回复:帮忙解释下function' : 'const char *' differs in levels of indirec ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.051187 second(s), 11 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved