I'm trying to make a function that auto populates data into a binary file if the file does not exist. Since it doesn't exist, I want to add data myself from a function so it can also create the file itself with the data.
The struct I made
struct Address {
char city[ADDR_SIZE];
char state[ADDR_SIZE];
int zipcode;
};
struct Record {
char name[NAME_SIZE];
int socialSecurityNum;
int dateOfBirth;
Address address;
};
I'm trying to add the data like this
dataFile.seekp(getBytePosition(0), ios::beg);
citizen.name = "Some name"; //ERROR: char[30] not assignable
citizen.socialSecurityNum = 123123123;
citizen.address.zipcode = 75042;
dataFile.write(reinterpret_cast<char *>(&citizen), sizeof(citizen));
Giving it integers is simple, but how do I make it populate the char name array?
I also tried these but failed
citizen.name[NAME_SIZE] = "Some name"; //Fails
citizen.name[NAME_SIZE] = {"Some Name"}; //Fails
citizen.name[NAME_SIZE] = 'Some Name'; //Too Many errors