I'm just learning C and I can't work out how to solve this undeclared error when compiling this code. I assume it has something to do with scope. Any help / explanation would be much appreciated
C code - 47 lines - codepad
Code:
#include <stdio.h>
int main(void) {
struct bank_account {
int accountNumber;
char * firstName;
char * lastName;
float balance;
char * password;
};
struct bank_account account_123;
account_123.accountNumber = 123;
account_123.firstName = "Oliver";
account_123.lastName = "Hough";
account_123.balance = 345.69;
account_123.password = "f4kep455w0rd";
display_account();
printf("\n");
return 0;
}
int display_account(void) {
printf("--------------------------------------------------\n");
printf(" Bank Account Details \n");
printf("--------------------------------------------------\n");
printf(" Account Number: %d\n", account_123.accountNumber);
printf(" Initials: %c %c\n", account_123.firstName[0], account_123.lastName[0]);
printf(" First Name: %s\n", account_123.firstName);
printf(" Last Name: %s\n", account_123.lastName);
printf(" Balance: €%.2f\n", account_123.balance);
printf(" Second character of Password: %c\n", account_123.password[1]);
printf(" Fourth character of Password: %c\n", account_123.password[3]);
printf(" Seventh character of Password: %c\n", account_123.password[6]);
return 0;
}
Thanks.