zhaohedavid zhaohedavid
关注数: 103 粉丝数: 84 发帖数: 3,724 关注贴吧数: 14
求大神啊求大神,附源程序文件 咳咳,先说问题吧,运用多文件的文件的打开及套用,还运用了结构体;编译也没有错误,主要是在子文件想要打开文件和引用结构体的内容就不行了。求大神告诉我为什么及要如何解决这个问题。 首先是主文件,如下: #include<stdio.h> #include<stdlib.h> struct goods{ int num1; char name[20]; char kind[20]; int in_price; int out_price; int num2; char gx_name[20]; }b[100]; #include<input.c> #include<look.c> #include<buy.c> #include<delete.c> #include<add.c> void main() { int i,j,s,m; long temp; for(i=0;i<30;i++) { printf("= "); } printf("\n *sale manage system* \n"); printf(" 1-input the information:\n"); printf(" 2-look the information:\n"); printf(" 3-buy goods:\n"); printf(" 4-total price:\n"); printf(" 5-pay for it right now:\n"); printf(" 6-delete the information:\n"); printf(" 7-modificate the information:\n"); printf(" 8-add the information:\n"); printf(" 9-complete:\n"); for(j=0;j<30;j++) { printf("= "); } printf("\nplease input your choice:\n"); scanf("%d",&s); switch (s) { case 1: printf("please input the information:\n"); printf("please input the amount of the goods:\n"); scanf("%d",&m); input(b,m); break; case 2: look(b,m); break; case 3: buy(b,m); break; case 4: printf("look the goods you have bought:\n"); printf("the total prices of the goods you have bought:"); break; case 5: printf("make sure pay for it:\n"); break; case 6: delete(b,m); break; case 7: printf("please input the goods' num you want to modificate:"); scanf("%ld",&temp); for(i=0;i<m;i++) { if(temp==b[i].num1) { printf("please input the goods' new num:"); scanf("%d",&b[i].num1); printf("please input the goods' new name:"); scanf("%s",b[i].name); printf("please input the goods' new kind:"); scanf("%s",b[i].kind); printf("please input the goods' new inprice:"); scanf("%d",&b[i].in_price); printf("please input the goods' new outprice:"); scanf("%d",&b[i].out_price); printf("please input this goods' new amount:"); scanf("%d",&b[i].num2); printf("please input the goods' new gx_name:"); scanf("%s",b[i].gx_name); } } printf("the information are:\n"); for(j=0;j<m;j++) { printf("num:%d \n",b[j].num1); printf("name:%s \n",b[i].name); printf("sort:%s \n",b[j].kind); printf("in_price:%d \n",b[j].in_price); printf("out_price:%d \n",b[j].out_price); printf("amount:%d \n",b[j].num2); printf("gx_name:%s \n",b[j].gx_name); } break; case 8: add(b,m); break; case 9: printf("Thanks for you to use our system!The system will exit.\n"); return; default: printf("there are some problems\nplease choose again\nthe menu will exit\n"); break; } } 
1 下一页