This is what I came up with, I am still being told buy_new is not a function. Also, did I do my loop right at the bottom. For loops have been an issue for me
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void menu();
double buy_new(int *total_games);
int main () {
int ans, newgames, usedgames, total_games, buy_new, i;
total_games = newgames + usedgames;
srand(time(0));
printf("\n");
menu();
scanf("%d", &ans);
while (ans != 3) {
if (ans == 1) {
buy_new(int *total_games);
}
else if (ans == 2) {
printf("How man used games would you like to buy?\n");
scanf("%d", usedgames);
}
else if (ans != 3)
printf("Sorry, invalid option. Please try again.\n");
printf("\n");
menu();
scanf("%d", &ans);
}
return 0;
}
void menu() {
printf("1.Buy new games.\n");
printf("2.Buy used games.\n");
printf("3.Quit.\n");
}
double buy_new (int *total_games) {
int newgames, price, i;
printf("How many new games would you like to buy?\n");
scanf("%d", &newgames);
for (i=0; i<newgames; i++)
{
price = rand() % ((5000-2500+1) + 2500) / 100;
}
}