For some reason, this very basic code will compile without errors in Visual C ++, but gives errors in Xcode. I will need to know why to continue working in Xcode for my Computer Science class.
#include <iostream>
#include <string>
using namespace std;
struct acct {
int num;
string name;
float balance;
};
int main() {
acct account;
cout << "Enter new account data: " << endl;
cout << "Account number: ";
cin >> account.num;
cout << "Account name: ";
cin >> account.name;
cout << "Account balance: ";
cin >> account.balance;
return 0;
}
This gives two errors, one of which says she expected ';' before the account (after main is declared), and the second this account was not declared for cin → account.num;
source
share