#include <stdio.h>

#include <stdlib.h>


typedef struct

{

    char *name;

    char *phone;

} Record;

#define TABLE_SIZE 128

#define INFO_SIZE 32

#define BUFFER_SIZE 256



int main()

{

    char name[INFO_SIZE], phone[INFO_SIZE], buffer[BUFFER_SIZE];

    Record records[TABLE_SIZE], *precords = records;

    int num_records = 0;

    while (fgets(buffer, sizeof(buffer), stdin) != NULL)

    {

        if(sscanf(buffer, "%s %s", name, phone) > 0)

        {

            Record record;

            record.name = name;

            record.phone = phone;

            records[num_records++] = record;

            printf("%d", num_records);

            printf("Name: %s, Phone: %s\n", precords -> name, precords -> phone);

        }

        else

            break;

    }

    for (int i = 0; i < num_records; i++)

    {

        printf("Name: %s, Phone: %s\n", precords -> name, precords -> phone);

        precords++;

    }

}

이 코드에서 이름하고 번호 여러개 입력하면 차례대로 출력되는게 아니라 마지막에 입력한걸로 다 덮어씌어져서 출력됨 이 오류 어케 고침??