急,不难,cannot convert parameter 2 from 'int *' to 'int'怎么解决error
// 仓库.cpp : Defines the entry point for the console application.//
#include "stdafx.h"
#include <stdio.h>
#include <conio.h>
#include <process.h>
#define MAX_NUM 1000
struct GOODS{
char num;//货物号
char name;//货物名
char facowner;//生产厂家factory owner
int num_same;//同类产品的数量
int price;//价格
int Zprice;//同类产品的总Z价格
char birthday;//生产日期
char D_stock;//进货stock日期date
char staff;//经手人
}ingoods;
int load_data_from_file(struct GOODS[],int *);//从文件加载数据到内部数据库
int save_data_to_file(struct GOODS[], int);//将内存数据库中的数据写入到文件中
int input_data_from_std(struct GOODS[], int *);//从标准输入输入数据
int display_data_to_std(struct GOODS[], int);//输出数据的函数
void oper_Inface();//遥控器
void jud();
void record();
void calcNZprice();
void calcNnum();
int judge;//全局变量
int main(int argc, char* argv[]){
//建立一个内存数据库
struct GOODS demo;
int nRealUsed_Num; //实际已录入的记录数
//程序启动时加载数据库
load_data_from_file(demo, &nRealUsed_Num);
char ch;
while(1){
system("cls"); //其声明也是包含 process.h,清屏效果
oper_Inface();//先显示用户的可选项即用户界面
//ch=getchar();会回显
ch=getch();//直接读按键,不回显 <conio.h>
switch(ch){
case'0':display_data_to_std(demo, nRealUsed_Num); break; //显示当前内存数据库中的所有数据
case'1': input_data_from_std(demo, &nRealUsed_Num);break;//录入货物信息
case'2': calcNZprice();break;//统计这批货物价值
case'3': break;
case'4': calcNnum();break;//统计这批货物数量
case'5': save_data_to_file(demo,nRealUsed_Num);//防止不小心按到该数字,没保存信息就结束。
exit(0); //可以终止程序的函数 <process.h>//而return 0;是终止函数
break;
default:
printf("您输入了无效按键(有效按键为:1 2 3 4 5)\n");
printf("please any key to operating interface...then input a valid num\n");
getch();
break;
}
}
save_data_to_file(demo,nRealUsed_Num);//程序退出时将内存中的数据保存数据到外存
return 0;
}
//从文件加载数据到内部数据库
int load_data_from_file(struct GOODS demo[], int *nRealUsed_Num) {
FILE *fp;
fp = fopen("database.datech", "rb");
if (fp == NULL) {
*nRealUsed_Num = 0;
return -1;
}
int i = 0;
while (fread((void*)&demo, sizeof(struct GOODS), 1, fp)>0)
{
i++;
}
*nRealUsed_Num = i;
fclose(fp);
return 0;
}
//将内存数据库中的数据写入到文件中
int save_data_to_file(struct GOODS demo[], int nRealUsed_Num) {
FILE *fp;
fp = fopen("database.datech", "wb");
if (fp == NULL) {
return -1;
}
for (int i = 0; i<nRealUsed_Num; i++) {
fwrite((void*)&demo, sizeof(struct GOODS), 1, fp);
}
return 0;
}
//显示操作界面
void oper_Inface(){
system("cls");
printf("-- 欢迎进入仓库管理系统--\n\n");
printf("0. 显示当前内存数据库中的所有记录\n\n");
printf("1. 录入货物信息\n\n");
printf("2. 统计货物总价值\n\n");
printf("3. \n\n");
printf("4. 货物总量\n\n");
printf("5. 退出系统\n\n");
printf("按0-5键,进行相应的操作\n\n");
}
/*void jud(){
char judge;
printf("继续录入货物信息?输入0,结束录入;任意键继续录入。");
scanf("%d",&judge);
switch(judge)
{
case 0: printf("Please any key to operating interface...\n");操作系统
default:record();
}
printf("Please any key to operating interface...\n");
getch();
}*/
//结束录入货物信息
void jud(){
printf("继续录入货物信息?输入0,结束录入;任意键继续录入:");
scanf("%d",&judge);
}
//录入货物信息
int input_data_from_std(struct GOODS demo[], int *nRealUsed_Num){
system("cls"); //其声明也是包含 process.h
int i;
i=*nRealUsed_Num;
printf("请输入货物信息:\n");
printf("货物号:\t货物名:\t生产厂家:\t同类产品的数量:\t价格:\t生产日期:\t进货日期:\t经手人:\t\n");
for(i=0;i<10;i++){
scanf("%s %s %s %d %d %s %s %s",&ingoods.num,&ingoods.name,&ingoods.facowner,&ingoods.num_same,&ingoods.price,&ingoods.birthday,&ingoods.D_stock,&ingoods.staff);
jud(); //调用函数判断是否还要输入货物信息
if(judge)continue;
else break;
}
save_data_to_file(demo,nRealUsed_Num);//将内存中的数据保存数据到外存
*nRealUsed_Num=++i;//i+1;//++i;//i++;
oper_Inface();
return 0;
}
int display_data_to_std(struct GOODS demo[], int nRealUsed_Num) {
if (nRealUsed_Num != 0) {
printf("货物号:货物名:生产厂家:同类产品的数量:价格:生产日期:进货日期:经手人:\n");
for (int i = 0; i<nRealUsed_Num; i++) {
printf("%s\t%s\t%s\t%d\t%d\t%s\t%s\t%s\n",ingoods.num,ingoods.name,ingoods.facowner,ingoods.num_same,ingoods.price,ingoods.birthday,ingoods.D_stock,ingoods.staff);
}
}
else printf("当前数据库暂时没有信息记录!\n");
return 0;
}
int calcNZprice(struct GOODS demo[], int nRealUsed_Num){
system("cls");
int NZprice=0;
for(int i=0;i<nRealUsed_Num;i++){
ingoods.Zprice=ingoods.num_same*ingoods.price;
NZprice+=ingoods.Zprice;
printf("%s这种货物价值为:%d\n",ingoods.name,ingoods.Zprice);
}
printf("这批货物总价值为:%d\n",NZprice);
printf("Please any key to operating interface...\n");
getch();
return 0;
}
int calcNnum(struct GOODS demo[], int nRealUsed_Num){
system("cls");
int Nnum=0;
for(int i=0;i<nRealUsed_Num;i++){
Nnum+=ingoods.num_same;
}
printf("这批货物总量为:%d\n",Nnum);
printf("Please any key to operating interface...\n");
getch();
return 0;
} save_data_to_file(demo,nRealUsed_Num);//将内存中的数据保存数据到外存 是这一行出error怎么解决error{:5_99:} 应该是你传入了一个int指针
看你的函数定义的第二个形参是int
页:
[1]