#include "stdafx.h"
#include <stdio.h>
#include<stdlib.h>
#include<iostream>
typedef struct Sale
{
int clientNumber[4];
char Item[45];
char PartNum[12];
int UniCost[11];
char DayOfMonth[20];
};
Sale rSale[197];
typedef struct Data
{
int clientNumber[4];
char Company[34];
char ABN[14];
char StreetName[36];
char Suburb[24];
char State[11];
char PostCode[5];
char Phone[15];
};
Data rData[10];
int _tmain(int argc, _TCHAR* argv[])
{
FILE *fp;
FILE *fps;
fp=fopen("clinet.txt","r");
fps=fopen("records.txt","r");
if ((fp != (FILE *)NULL) && (fps != (FILE *)NULL) )
{
int x,j,i,b;
j=0;
for (x=0; x<10; x++)
{
fread(rData[x].clientNumber,10,3,fp);
fgets(rData[x].Company,sizeof(rData[0].Company),fp);
fgets(rData[x].ABN,sizeof(rData[0].ABN),fp);
fgets(rData[x].StreetName ,sizeof(rData[0].StreetName),fp);
fgets(rData[x].Suburb,sizeof(rData[0].Suburb),fp);
fgets(rData[x].State,sizeof(rData[0].State),fp);
fgets(rData[x].PostCode,sizeof(rData[0].PostCode), fp);
fgets(rData[x].Phone,sizeof(rData[0].Phone),fp);
}
for (i=0; i<197 ;i++)
{
fread(rSale[i].clientNumber,1,3,fps);
fgets(rSale[i].ItemDesc,sizeof(rSale[i].ItemDesc),fps);
fgets(rSale[i].PartNum,sizeof(rSale[i].PartNum),fps);
fread(rSale[i].UniCost,3,7,fps);
fgets(rSale[i].DayOfMonth,sizeof(rSale[i].DayOfMonth),fps);
}
for (b=0;b<10;b++)
{
printf("TOF ------------ \n\n\n");
printf("ABN %s\n",rData[b].ABN);
printf("%s\n",rData[b].Company);
printf("%s\n",rData[b].StreetName);
printf("%s %s %s\n",rData[b].Suburb,rData[b].State,rData[b].PostCode);
printf("%s\n\n\n\n",rData[b].Phone);
for (j=0;j<197;j++)
{
if(*(rData[b].clientNumber) == *(rSale[j].clientNumber))
{
printf("%s%s$%s%s",rSale[j].ItemDesc,rSale[j].PartNum,rSale[j].UniCost,rSale[j].DayOfMonth);
printf("%i",totalunitcost)[inlinecode]can u guys help do the totalunitcost for each specific customer, i tried everything could get it done thank u[/inlinecode]
}}}
}
}
int k;
scanf("%i", k);
return 0;
}
alksja 0 Newbie Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
alksja 0 Newbie Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.