Hello, I am trying to do a string copy in C++. I have gotten the first one in my code to work, but the next one that accesses my classes does not work. The string compares however do.
Code:
void Phonebook::delFriend(int * index, Phonebook * pb){
int i = 0;
int j = 0;
string fn;
string ln;
char buffer[20];
string str ("Test...");
str.copy(buffer, MAX_NAME_LENGTH);
cout<<buffer;
cout<<"Firstname: ";
cin>>fn;
cout<<"Lastname: ";
cin>>ln;
cout<<"...Friend deleted\n";
for(i = 0; i < * index; i++){
if((fn.compare(pb[i].get_firstName(i)) ==0) && (ln.compare(pb[i].get_lastName(i)) ==0)){
for(j = 0; j < *index; j++){
pb[j+1].get_firstName(j+1).copy(pb[j].get_firstName(j), MAX_NAME_LENGTH);
//strcpy(pb[j].lastName, pb[j+1].lastName);
//strcpy(pb[j].homeNumber, pb[j+1].homeNumber);
//strcpy(pb[j].cellNumber, pb[j+1].cellNumber);
}
}
}
*index -= 1;
}