Code:
#include <stdio.h>
typedef int weeks[13];
struct sale
{
int week;
char name;
int units;
int price;
}sale;
int main (void)
{
int week;
int unit;
int cost;
sale.week = week;
sale.units = unit;
sale.price = cost;
char filename1;
char filename2;
char output;
int maxsale= 0;
int maxweek= 0;
int tc1;
char cbuff[5];
FILE *pointer1;
FILE *pointer2;
printf("please enter the filename to open\n");
scanf("%s",&filename1);
printf("please enter the filename to write to\n");
scanf("%s",&filename2);
pointer1 = fopen(filename1,"r");
if (pointer1 == NULL)
{
printf("file failed to open");
}
pointer2 = fopen(filename2,"w");
if (pointer2 == NULL)
{
printf("file failed too open");
}
while(fgets(cbuff,1000,pointer1)!=NULL)
{
sscanf(pointer1,"%d\t%s\t%d", &sale.week, &sale.units, &sale.price);
if (cost > maxsale)
{
maxsale = cost;
maxweek = week;
}
fprintf(pointer2,"week no\t\t Total sales\n");
if (week == "1")
{
(tc1= (cost * unit) + tc1);
fprintf(pointer2,"%d \t\t %d\n",sale.week,tc1);
}
tc1=0;
if (week == "2")
{
(tc1= (cost * unit) + tc1);
fprintf(pointer2,"%d \t\t %d\n",sale.week,tc1);
}
tc1=0;
if (week == "3")
{
(tc1= (cost * unit) + tc1);
fprintf(pointer2,"%d \t\t %d\n",sale.week,tc1);
}
tc1=0;
if (week == "4")
{
(tc1= (cost * unit) + tc1);
fprintf(pointer2,"%d \t\t %d\n",sale.week,tc1);
}
tc1=0;
if (week == "5")
{
(tc1= (cost * unit) + tc1);
fprintf(pointer2,"%d \t\t %d\n",sale.week,tc1);
}
tc1=0;
if (week == "6")
{
(tc1= (cost * unit) + tc1);
fprintf(pointer2,"%d \t\t %d\n",sale.week,tc1);
}
tc1=0;
if (week == "7")
{
(tc1= (cost * unit) + tc1);
fprintf(pointer2,"%d \t\t %d\n",sale.week,tc1);
}
tc1=0;
if (week == "8")
{
(tc1= (cost * unit) + tc1);
fprintf(pointer2,"%d \t\t %d\n",sale.week,tc1);
}
tc1=0;
if (week == "9")
{
(tc1= (cost * unit) + tc1);
fprintf(pointer2,"%d \t\t %d\n",sale.week,tc1);
}
tc1=0;
if (week == "10")
{
(tc1= (cost * unit) + tc1);
fprintf(pointer2,"%d \t\t %d\n",sale.week,tc1);
}
tc1=0;
if (week == "11")
{
(tc1= (cost * unit) + tc1);
fprintf("pointer2,%d \t\t %d\n",sale.week,tc1);
}
tc1=0;
if (week == "12")
{
(tc1= (cost * unit) + tc1);
fprintf(pointer2,"%d \t\t %d\n",sale.week,tc1);
}
tc1=0;
}
fprintf(pointer2,"the max sale was %d and the max week was %d\n",&maxsale,&maxweek);
fclose(pointer1);
fclose(pointer2);
}
can any one give me some ideas before midday (thats when it has to be emailed in)