Am getting this error message for the following code, but it doesn’t make sense at all. Can you please check this code and tell what’s wrong? Have commented the code on the relevant line.
#import <Foundation/Foundation.h>
typedef struct {
float exchangeRate;
double budget;
double euroTransaction;
} budget;
int main(int argc, const char * argv[])
{
budget vacationBudget;
void spendDollars (double dollars) { //Expected ';' at end of declaration
vacationBudget.budget -= 100;
}
void chargeEuros(double euros) {
vacationBudget.euroTransaction = euros*vacationBudget.exchangeRate;
vacationBudget.budget -= vacationBudget.euroTransaction;
}
vacationBudget.exchangeRate = 1.2500;
vacationBudget.budget = 1000.00;
double numberDollars = 100;
double numberEuros = 100;
spendDollars(numberDollars);
NSLog(@"Converting %.2f US dollars into euros leaves $%.2f", numberDollars, vacationBudget.budget);
NSLog(@"Charging %.2f euros leaves $%.2f", numberEuros, vacationBudget.budget);
return 0;
}
Funcitions can’t be inside main. Change to: