I have the following data structure:
struct file{
char name[MAX_FILE_NAME];
char data[BLOCK_SIZE - MAX_FILE_NAME]
};
struct disk{
vector<file> current_file;
};
When I try to modify something say in index 0 of whatever disk I’ve created like so:
disk new_disk;
new_disk.current_file[0].name = "new name";
I get the error that expression must be a modifiable |value
I feel like it’s late and I just can’t seem to understand something simple… but why won’t that work?
You can’t assign arrays like that, e.g.
You have to use a function like
strcpystrncpywould be safer, andstd::stringwould be even safer.