Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove a inside struct from function #1

Open
309631 opened this issue Jun 4, 2021 · 0 comments
Open

remove a inside struct from function #1

309631 opened this issue Jun 4, 2021 · 0 comments

Comments

@309631
Copy link
Owner

309631 commented Jun 4, 2021

Put a global variable?

`void marketing(char *filename, char *filename1){
system("cls");

	float sumP,sumGF,sumPf,sumPP;


//	char* P[20],GF[20],Pf[20],PP[20];


	


	


	PRODUCTO Premium;


		strcpy(Premium.Name,"Premium");


		Premium.Price = 5;


	


	PRODUCTO Gold_funds;


		strcpy(Gold_funds.Name,"Gold funds");


		Gold_funds.Price = 10;






	PRODUCTO Premium_funds;


		strcpy(Premium_funds.Name,"Premium funds");


		Premium_funds.Price = 15;


	PRODUCTO Premium_Plus;


		strcpy(Premium_Plus.Name,"Premium Plus");


		Premium_Plus.Price = 20;






	


	CUSTOMER marketingInfo,randomhuj;


	PRODUCTO productInfo;


	


	FILE *fp=NULL;	


	fp = fopen(filename,"rb");


		if (fp == NULL)


	{


		printf("File open ERROR");


		getch();


		exit(1);	


	}


	FILE *fp1=NULL;


	fp1 = fopen(filename1,"rb");


		if (fp1 == NULL)


	{


		printf("File open ERROR");


		getch();


		exit(1);	


	}


	


	fread(&productInfo,sizeof(PRODUCTO),1,fp1);


//	fread(&randomhuj, sizeof(CUSTOMER),1, fp);


	//&& fread(&productInfo, sizeof(PRODUCTO),1 , fp) != 0 


	while(fread(&marketingInfo, sizeof(CUSTOMER),1 , fp) != 0)


	


	/* DONE (#1#): Problem with data comparison, same with 


	               password function? */


	{


		/* TODO (#1#): POPRAWIÆ TUTAJ */


//		&&strcmp(productInfo.Name,"Premium")


		if(strcmp(marketingInfo.Produto.Name,Premium.Name)==0)


		{


			sumP+=productInfo.Price*marketingInfo.Quantidade;	


//			P = &productInfo.Name;


//			strcpy(P,productInfo.Name);


		}


		else if(strcmp(marketingInfo.Produto.Name,Gold_funds.Name)==0)


		{


			sumGF+=productInfo.Price*marketingInfo.Quantidade;	


//			GF=productInfo.Name;


		}


		else if(strcmp(marketingInfo.Produto.Name,Premium_funds.Name)==0)


		{


			sumPf+=productInfo.Price*marketingInfo.Quantidade;	


//			Pf=productInfo.Name;


		}


		else if(strcmp(marketingInfo.Produto.Name,Premium_Plus.Name))


		{


			sumPP+=productInfo.Price*marketingInfo.Quantidade;	


//			PP=productInfo.Name;


		}


		


	}


	printf("%s | %.2f |%.2f\n",Premium.Name,Premium.Price,sumP);


	printf("%s | %.2f\n",Gold_funds.Name,sumGF);


	printf("%s |%.2f\n",Premium_funds.Name,sumPf);


	printf("%s | %.2f",Premium_Plus.Name,sumPP);


//	printf("%.2f",sumGF);


	fclose(fp);


	getch();


	system("cls");


}


<!--EndFragment-->`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant