aboutsummaryrefslogtreecommitdiff
path: root/contactList.c
diff options
context:
space:
mode:
Diffstat (limited to 'contactList.c')
-rw-r--r--contactList.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/contactList.c b/contactList.c
index 9c6640c..891054c 100644
--- a/contactList.c
+++ b/contactList.c
@@ -62,6 +62,17 @@ int addContact(const contact* cnct) {
contactList = realloc(contactList, nbContacts * sizeof *contactList);
memcpy(&contactList[nbContacts-1],cnct, sizeof *cnct);
}
+int deleteContact(contact* cnct) {
+ if( cnct->conversation ) {
+ *cnct->name = 0;
+ strcpy(cnct->display_name, cnct->number);
+ } else {
+ int index = cnct - contactList;
+ fprintf(stderr, "Index %d\n", index);
+ memmove(contactList+index, contactList + index + 1, (nbContacts-index-1) * sizeof(contact));
+ nbContacts--;
+ }
+}
int fillContactList(const char* filename) {
FILE* file = fopen(filename, "r");