I'm not understanding why these assignments are failing.
Here are the struct definitions:
Code:
struct Connection {
FILE *fp;
struct Core *core;
};
struct Core {
struct Config *cnf;
struct Database *db;
};
struct Config {
int size;
int free_index;
int delete_index;
};
struct Database {
struct Information *rows;
};
struct Information {
int index;
char name[MAX_DATA];
char phone[MAX_DATA];
};
Code:
void DatabaseSort(struct Connection *conn)
{
int i;
char *tmp1;
char *tmp2;
for (i = 0; i < conn->core->cnf->delete_index; i++)
if ((strncmp(conn->core->db->rows[i].name, conn->core->db->rows[i + 1].name, MAX_DATA)) == 1) {
tmp1 = conn->core->db->rows[i + 1].name;
tmp2 = conn->core->db->rows[i + 1].phone;
conn->core->db->rows[i + 1].name = conn->core->db->rows[i].name; -----> error: incompatible types in assignment
conn->core->db->rows[i + 1].phone = conn->core->db->rows[i].phone; -----> error: incompatible types in assignment
conn->core->db->rows[i].name = tmp1; -----> error: incompatible types in assignment
conn->core->db->rows[i].phone = tmp2; -----> error: incompatible types in assignment
}
}
Can't a pointer be assigned to another pointer?
-Tristan