any type of suggestion/correction will do, and i can't seem to get my functions to work or my conditional statements.
int buyitem(int x, int y)//* function used to buy an item at any store*//
{
int bought;
bought=x-y;
return bought; //*returns the value of the difference bet wen x and y*//
}
void Tycoons(int *gil,int *onhand,int *day,int *debt)//*function used as a shop, it does not return anything*//
{
int i, g, on, d, de, count, N, p1, p2, p3, p4, p5, p6, p7, p8, option;
d=*day;
g=*gil;
de=*debt;
on=*onhand;
srand(time(NULL));
p1=rand()%1201+500;
p2=rand()%2101+1500;
p3=rand()%7001+5000;
p4=rand()%5501+3500;
p5=rand()%12001+8000;
p6=rand()%30001+15000;
p7=rand()%70001+40000;
p8=rand()%65001+35000;
system("cls");
printf("************************\n");
printf("Tycoon Meteor's Minerals\n");
printf("************************\n");
printf("\n");
printf("Shopkeeper: Welcome! How may I be of service?\n");
printf("\n");
printf("Item On hand Price\n");
printf("\n");
printf("Phoenix Down %d %dG\n", on, p1);
printf("Elixir Essence %d %dG Day #%d\n",on, p2, d);
printf("Platinum Ingot %d %dG Gil:%d\n", on, p3, g);
printf("Golden Materia %d %dG Debt:%d\n", on, p4, de);
printf("Scarlette %d %dG\n",on, p5);
printf("Adamintite %d %dG\n",on, p6);
printf("Dark Matter %d %dG\n",on, p7);
printf("Trapezohedron %d %dG\n",on, p8);
printf("\n");
printf("[1]Buy [2]Sell [3]eave\n");
printf("\n");
printf("Option: ", option);
scanf("%d", &option);
if(option == 1)
{
system("cls");
printf("************************\n");
printf("Tycoon Meteor's Minerals\n");
printf("************************\n");
printf("\n");
printf("Shopkeeper: Buying an item? Which one?\n");
printf("\n");
printf("Item On hand Price\n");
printf("\n");
printf("[1]Phoenix Down %d %dG\n", on, p1);
printf("[2]Elixir Essence %d %dG Day# %d\n",on, p2, d);
printf("[3]Platinum Ingot %d %dG Gil:%d\n", on, p3, g);
printf("[4]Golden Materia %d %dG Debt:%d\n", on, p4, de);
printf("[5]Scarlette %d %dG\n",on, p5);
printf("[6]Adamintite %d %dG\n",on, p6);
printf("[7]Dark Matter %d %dG\n",on, p7);
printf("[8]Trapezohedron %d %dG\n",on, p8);
printf("\n");
printf("[1]Buy [2]Sell [3]Leave\n");
printf("\n");
printf("Option: ", option);
scanf("%d", &option);
if(option == 1 || option == 2 || option == 3 || option == 4|| option == 5 || option == 6 || option == 7 || option ==8)
{
printf("How Many?: ", N);
scanf("%d", &N);
if(N>0 && g>p1)
{
buyitem(g,p1);
Tycoons(gil,onhand,day,debt);
}
}
}
else if(option == 3)
{
main();
d++;
}
else
{
printf("wrong option");
Tycoons(gil,onhand,day,debt);
}
}
int main()
{
int d, g, de, Choice, on, p1, p2, p3, p4, p5, p6, p7, p8;
char quit;
d = 1;
g=20000;
de=50000;
char option;
on= 0;
srand(time(NULL));
system("cls");
printf("\n");
printf("Gilgamesh: Where should my travels take me to?\n");
printf("\n");
printf("[1]Tycoon Meteor's Minerals Day #%d\n", d);
printf("[2]Pulsian Restoratives Gil: %d\n", g);
printf("[3]Archadian Luxuries Debt: %d\n", de);
printf("[4]Cid's Magical Escapades\n");
printf("[5]Gaian Gratitudes\n");
printf("[6]Riches and Minerals of Spira [Q]uit\n", quit);
printf("[7]Go see the Merchant of The Rift\n");
printf("\n");
printf("Your Choice: ", Choice);
scanf("%d", &Choice);
switch(Choice)
{
case 1:
Tycoons(&g,&on,&d,&de);
break;
case 'q':
printf("Thank you for playing!");
exit(0);
break;
}
getch();
}
int
s by pointer? – Alex Chamberlain Aug 12 '12 at 11:49