I am a beginner in coding in objective-C and don't understand why there is an error in this code. I know this is a little obnoxious, but like I said, I am new and want to give everyone the full code so I don't miss something. It is saying that I am using an undeclared identifier in the last part of my code, in the void(s), "theBudget", "dollars", and "foreignCurrency".
Code:
#include <stdio.h>
typedef struct {
float exchangeRate;
double budget;
double exchangeTransaction;
} budget;
budget vacationBudgetEurope;
budget vacationBudgetEngland;
void spendDollars(budget *theBudget, double dollars);
void chargeForeignCurrency (budget *theBudget, double foreignCurrency);
int main(int argc, const char * argv[])
{
// Decalartion of Variables
vacationBudgetEurope.exchangeRate = 1.2500;
vacationBudgetEurope.budget = 1000.00;
double numberDollarsEurope = 100;
double numberEuros = 100;
//More declaration, just grouped by similarity
vacationBudgetEngland.exchangeRate = 1.5000;
vacationBudgetEngland.budget = 2000.00;
double numberDollarsEngland = 100;
double numberPounds = 100;
spendDollars (&vacationBudgetEurope, numberDollarsEurope);
printf("Converting %.2f US dollars into euros leaves $%.2f", numberDollarsEurope, vacationBudgetEurope.budget);
chargeForeignCurrency(&vacationBudgetEurope, numberEuros);
printf("Charging %.2f euros leaves $%.2f", numberEuros, vacationBudgetEurope.budget);
spendDollars(&vacationBudgetEngland, numberDollarsEngland);
printf("Converting %.2f US dollars into pounds leaves $%.2f", numberPounds, vacationBudgetEngland.budget);
chargeForeignCurrency(&vacationBudgetEngland, numberPounds);
printf("Charging %.2f pounds leaves $%.2f", numberPounds, vacationBudgetEngland.budget);
void spendDollars(budget *theBudget, double dollars);
{
theBudget->budget -= dollars;
}
void chargeForeignCurrency(budget *theBudget, double foreignCurrency);
{
theBudget->exchangeTransaction = foreignCurrency*theBudget->exchangeRate;
theBudget->budget -= theBudget->exchangeTransaction;
}
return 0;
}
Last edited by a moderator: