PROGRAM FOR AUCTIONING OF AN OBJECT WITH TIME LIMIT

This program is a mini project not any JNTU question.. 



#include <stdio.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#define maxim(x,y) (x>y?x:y)
void winner();
void bid();
void timea();
void timeb();
char ss[100], *zz,mms[30];
FILE *fp;
int w=0;
char x='A',vvv,t[21][21];
int long e=0;
char a[100],q[100],u;
int long f=0,i=0;
int c=0,d=0,r=0,v;



void main()
{
printf("\nEnter the Topic of the bid:");
gets(q);
printf("\nEnter the no of bidders participating in the bid : ");
scanf("%d",&r);
scanf("%c",&vvv);
for(v=0;v<r;v++)
{
printf("\nEnter the Name of bidder %d :",v+1);
gets(t[v]);
}
printf("\nThe bidder ID are displayed below");
for(v=0;v<r;v++)
{
printf("\n %d - %s",v+1,t[v]);
}
printf("\nPress Enter key to start");

fp=fopen("AUCTION INFO.TXT","a");
bid();
}




void bid()
{
for(v=1;;v++)
{
fputs(" ------------------------------------------ ",fp );
fputs(" \n ",fp );
fputs(" \n ",fp );
fputs(" \n ",fp );
fputs( q ,fp );
fputs(" - ",fp );
scanf("%c",&vvv);

printf("\nEnter the name and specification of the object to bid:");
gets(a);
fputs( a ,fp );
timeb();
printf("\nEnter the minimum bid of the object :");
scanf("%ld",&i);
e=i;
printf("\n Now the users can start their bid");
for( ; ; )
{
scanf("%c",&vvv);
timea();
x='A';
printf("\n You are bidding for %s ",a);
printf(" \n Enter your ID :");
scanf("%d",&c);
printf(" \n the minimum bid of the object is %d \n Enter a greater bid: ",e);
scanf("%ld",&f);
e=maxim(f,e);
if(e==f)
{
w=c;
}
}
}
}




void timeb()
{
char *f;
time_t now;
struct tm ts;
char buf[80];
time(&now);
ts = *localtime(&now);
strftime(buf, sizeof(buf), "%H:%M:%S", &ts);
f=buf;
fputs(" TIME ",fp);
fputs(f,fp);
fputs("\n",fp);
}



void timea(void)
{
char f[80];
time_t now;
struct tm ts;
char buf[80];
time(&now);
ts = *localtime(&now);
strftime(buf, sizeof(buf), "%*%M%S", &ts);
strcpy(f,buf);
printf(" \nyou have 1 minute to bid or bid closes\n");

while(1)
{
time_t now;
struct tm ts;
char buf[80];
time(&now);
ts = *localtime(&now);
strftime(buf, sizeof(buf), "%*%M%S", &ts);
if(buf[1]>=(f[1]+1) &&( buf[2]>=f[2] ||buf[1]>=(f[1]+2) ) && ( buf[3]>=f[3] ||buf[1]>=(f[1]+2) ))
{
printf("\nBidding time is up ");
winner();
}
if(x=='B')
break;
scanf("%c",&vvv);
printf("\nEnter 'B' to bid ");
scanf("%c",&x);
vvv=x;
}

}




void winner()
{
char *win, *mm;
printf("\nThe Winner of the bid is %d - %s \n and his bid is %ld",w,t[w-1],e);
fputs("\nThe winner of the bid is ",fp);
win=t[w-1];
fputs(win,fp);
ltoa(e, mms,10);
fputs(" \n ",fp );
fputs("and his bidding price is ",fp);
fputs(mms,fp);
fputs(" \n ",fp );
fputs(" \n ",fp );
fputs(" \n ",fp );
printf("For another bid enter B else to quit enter Q:");
scanf("%c",&vvv);
scanf("%c",&u);
//scanf("%c",&vvv);
if(u=='B')
bid();
else if(u=='Q')
{
fclose(fp);
exit(1);
}
}