Lấy giá trị lên hàm phụ như thế nào?

Mình muốn lấy lệnh count1 ở dưới để dô hàm cho nó chạy for từ i < count1 thì làm sao ạ. Mình mới tập mong mn giúp đỡ.

#include <stdio.h>
#include <conio.h>
#include <malloc.h>
struct data
{
	char name[30];
	char numberphone[15];
	char nameproduct[30];
	int numberproduct[15];
	int ID[30];
	int cost[30];
	int count[5];
};
void NameCustomer(data* dt)
{
	fflush(stdin);
	printf("Enter name customer: ");
	gets_s(dt->name);
	fflush(stdin);
	printf("Enter numberphone: ");
	gets_s(dt->numberphone);
}
void Output(data dt,int count1)
{
	struct data *p;
	p = NULL;
	printf("===================================");
	printf("\nName: %s", &dt.name);
	printf("\nNumberphone: %s", &dt.numberphone);
	printf("\n===================================");
	for (int i = 0; i < count1; i++)
	{
		fflush(stdin);
		printf("NameProduct        Number        Cost");
		printf("%s %15d %20d ", (p + i)->nameproduct, (p + i)->numberproduct, (p + i)->cost);
	}
}
void main()
{
	data dt;
	NameCustomer(&dt);
	struct data *p;
	int Total = 0;
	int	d, i;
	int count1 = 0;
	p = (data*)malloc(100 * sizeof(data));
	for (i = 0;; i++)
	{
		fflush(stdin);
		printf("Enter 1 to buy or Enter 0 to close:");
		scanf_s("%d", &d);
		if (d == 1)
		{
			*(p + i)->count = 0;
			fflush(stdin);
			printf("Enter Name product: ");
			gets_s((p + i)->nameproduct);
			fflush(stdin);
			printf("Number of product: ");
			scanf_s("%d", (p + i)->numberproduct);
			fflush(stdin);
			printf("Cost of product:");
			fflush(stdin);
			scanf_s("%d", (p + i)->cost);
			count1++;
		}
		else break;
	}
	Output(dt);
	_getch();
}
83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?