I'm trying to pass various strings into members of a Struct via pointer but I am doing something fundamentally incorrect. What I think is that it doesn't need to be dereferenced. The process below works for other types of data such as int or char. For example:
typedef struct Course {
string location[15];
string course[20];
string title[40];
string prof[40];
string focus[10];
int credit;
int CRN;
int section;
} Course;
void c_SetLocation(Course *d, string location){
d->location = location;
. . .
}
I get an error when I try to compile the following algorithm to initialize a Course:
void c_Init(Course *d, string &location, ... ){
c_SetLocation(d, location[]);
. . .
}
The error:
error: cannot convert ‘const char*’ to ‘std::string* {aka std::basic_string<char>*}’ for argument ‘2’ to ‘void c_Init(Course*, std::string*, ..