There's nothing to convert, element access is the same with vectors.
Edit: but of course only once they exist as a result of calling resize or push_back/insert.
bool read_member_struct_from_file ( ifstream& file, Member& member )
// precondition: the ifstream is already opened for reading
// postcondition: if no data left in file (i.e. encountering EOF), then 'false' is returned as boolean function-value
// else : 1) the 'member'-reference parameter will be filled with file-data for one member-struct
// and 2) 'true' will be returned as boolean function-value
{
getline ( file, member.surname );
if ( !file ) // in case of encountering EOF-token
returnfalse ;
getline ( file, member.forename );
getline ( file, member.street_name );
getline ( file, member.postcode );
getline ( file, member.city_name );
char birth_year_string [6] ; // auxiliary variable!
file.getline( birth_year_string, 6 ) ; // use of 'getline' not possible to read in a number!
member.year_of_birth = atoi ( birth_year_string ) ; // .. atoi(..) : conversion array -> int
// atoi ( ...) only works with c-strings and not with 'string-class'-variables
string token_string ; // auxiliary variable!
getline ( file, token_string ); // use of 'getline' not possible to read in an 'enum'- nor a 'bool'-value
char token = token_string [ 0 ] ; // only first token!
if ( token == 'M' ) // also possible: if ( token_string [ 0 ] == 'M' )
member.gender = Male ;
else
member.gender = Female;
getline( file, token_string );
token = token_string [ 0 ] ; // only first token!
member.paid = ( token == 'T') ; // assigning bool-value
returntrue ;
}
I have added some conditions to make it more clear.
Yes i am sure that i did not change anything else.
It correctly shows the output table, but the table is empty.
The data from members.txt should be in it.
I don't know what the output table is. Did it print "There are no members found!" or not?
You must have change the calling code to not pass in the amountofmembers parameter. Did you change the rest of your code so that you use the vector size() function instead of that other variable?
Based on your code, that shouldn't be possible. store_data always prints a message at the end, which I don't see in the screenshot. So you're probably not calling the function at all (or you forgot to recompile).
Edit: by the way, store_data is a strange name for a function that loads data from a file. While one could argue that it stores it in the vector, this is against conventions.
I'm not seeing any "There are no members found!" or "From <x> members their data are known" output. I'd say you're not calling the function you think you are. Can you post the rest of the code that calls store_data().