
December 2nd, 2012, 09:24 PM
|
|
Registered User
|
|
Join Date: Dec 2012
Posts: 1
Time spent in forums: 41 m 15 sec
Reputation Power: 0
|
|
|
Help With Program
For some reason my program is not looping I need it to keep scanning but it stops can any one help
Code:
for(i=0; i<numEvents; i++)<--This will not loop
{
fscanf(ifp, "%s %s", &string1[i],&string2[i]);
fscanf(ifp,"%d",&temp[i]);
action = scaninput(string1[i],string2[i]);
if (action == 1) //Buy ticket
{
ticket_door=temp[i];
total_ticket_door = total_ticket_door + ticket_door;//Getting Total Number of tickets sold at the door
total_tickets= total_ticket_door + num_presale;//total tickets sold for event
fprintf(ofp,"Sold tickets %d - %d\n",m,m+ticket_door-1);
for(i=0; i<ticket_door; i++)
{
guests[m]= m;//Assigning all tickets bought to guests
m++;
}
}
else if (action==2) //Buy Raffle
{
num_raffles_bought=temp[i];//Temp = number of raffles bought
fscanf(ifp,"%d",&person);//
fprintf(ofp,"RAFFLE tickets %d - %d given to %d\n",r,r+num_raffles_bought,person);
for(i=0; i<num_raffles_bought; i++)
{
raffles_sold[r]=person;
r++;
}
}
else if (action==3) //Buy Drink
{
}
else if(action==4) //Award Raffle
{
}
else if(action==5) //Award Auction
{
}
else if (action==6) //BID Item
{
}
else if (action==7) //Total Revenue
{
}
}
return 0;
}
int scaninput(char word1[], char word2[])
{
int i;
if(strcmp(word1,"BUY")== 0) //if scan is BUY scan next next word
{
if(strcmp(word2,"TICKET")== 0)
{
return 1;
}
else if (strcmp(word2,"RAFFLE")==0)
{
return 2;
}
else if(strcmp(word2,"DRINK")==0)
{
return 3;
}
}
else if(strcmp(word1,"AWARD")==0) //Award Option
{
if(strcmp(word2, "RAFFLE")==0)
{
return 4;
}
else if(strcmp(word2, "AUCTION")== 0)
{
return 5;
}
}
else if(strcmp(word1,"BIDITEM"== 0))
{
return 6;
}
else if(strcmp(word1,"TOTAL")==0)
{
return 7;
}
}
Input Looks like this
5
BUY TICKET 8
BUY TICKET 10
BUY TICKET 1
BUY TICKET 3
BUY RAFFLE 2 5
|