You probably need to use the same kind of format as the others to read the entire field and then extract the code if it's present.
Below I've also tried to limit the amount that can be read into each field appropriately (and I've changed some sizes).
Note that you can also add the new node to the front of the list, which is easier.
Code:
typedef struct phonebook {
char phoneNumber[20];
char code[10];
char name[50];
char address[100];
char status[10];
struct phonebook *next;
} Phonebook;
void createList() {
char line[200];
FILE *fp = fopen("phonebook.txt", "r");
while (fgets(line, 200, fp)) {
Phonebook *temp = (Phonebook*)malloc(sizeof(Phonebook));
sscanf(line, " %19[^|]| %49[^|]| %99[^|]| %9s",
temp->phoneNumber, temp->name, temp->address, temp->status);
temp->next = NULL;
// Extract code if present
temp->code[0] = '\0';
char *p = strchr(temp->phoneNumber, 'x');
if (p) {
strncat(temp->code, p, 9);
if (p[-1] == ' ') --p;
*p = '\0';
}
// printf("[%s] [%s] [%s] [%s] [%s]\n", temp->phoneNumber, temp->code,
// temp->name, temp->address, temp->status);
int hash_value = abs(atoi(temp->phoneNumber)) % MAX;
temp->next = hashTable[hash_value];
hashTable[hash_value] = temp;
}
fclose(fp);
}