Originally posted by gvector1
lname = readline->substr(8,19);
lname is declared as "char lname[20]"
readline is the string that holds the line from the file
you cannot do something like that. lname stores the address of 20 bytes of memory allocated for the array. the statement "name = readline->substr(8, 19);" attempts to change the address of lname to the value returned by substr().
what you want to do is copy the string into the lname buffer:
Code:
std::string sub = readline->substr(8, 19);
strncpy(lname, sub.c_str(), sub.size());
lname[sub.size()] = NULL;