void suppliers()


{
	char linestr[200]; char outstr[80];
	char sdate[10], sitem[30], squantity[20], srate[10], stotal[10];
	int i,j,k,N =0;
	FILE *fp; FILE* fpout;
	fp = fopen("suppliers.txt", "r" );

	if (fp == NULL)
	{
		cout << "Could not open file" << endl;
		return -1;
	}

	fpout = fopen ("supplierfm.txt", "w");
	
	if (fpout == NULL)	
	{
		cout << "Could not create output file" << endl;
		return -1;
	}


/*Input file is open at this point, read records one by one */

	fgets(linestr, 199, fp);
	while (!feof (fp))
	{

/* valid string, separate the parts */

	i =0; k =0;
	while ((sdate[i++] = linestr[k++]) != ',');
	sroll[i-1]='\0'; i=0;

	while ((sitem[i++] = linestr[k++])!= ',');
	for (j = i-1; j<29; j++) sitem[j] = ' ';
	sitem[29] ='\0'; i=0;

	while ((squantity[i++] = linestr[k++]) != ',');
	for (j = i-1; j<19; j++) squantity[j] = ' ';
	squantity[19] ='\0'; i=0;	

	while ((srate[i++] = linestr[k++]) != ',');
	for (j = i-1; j<9; j++) srate[j] = ' ';
	srate[9] ='\0'; i=0;

	while ((stotal[i++] = linestr[k++]) != ',');
	for (j = i-1; j<9; j++) stotal[j] = ' ';
	stotal[9] ='\0'; i=0;


/* prepare output string and write to database*/


	sprintf(outstr, "%3d %10s %30s %20s %10s %10s\n",N,sdate,sitem,squantity,srate,stotal);
	fputs(outstr,fpout);
	fgets(linestr, 79, fp);
	N=N+1;
	}
	cout << "Supplier's Record\n";
	
	fclose(fp); fclose(fpout);
	return 0;



}