我有一个代码:
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
typedef struct NOTE
{
char NAME[50],
TELE[30];
int BDAY[3];
} NOTE;
void AddNote(NOTE * Notes, int NotesCount, NOTE * Temp)
{
Notes = (struct NOTE *) realloc(Notes, (NotesCount + 1) * sizeof(struct NOTE));
memcpy(Notes + NotesCount, Temp, sizeof(struct NOTE));
}
void main()
{
int NotesCount = 0, i = 0, f = 0;
int a;
NOTE * BLOC_NOTE, * Temp;
Temp = (struct NOTE *) malloc(sizeof(struct NOTE));
BLOC_NOTE = (struct NOTE *) calloc(0, sizeof(struct NOTE));
for(i = 0; i < 4; i++)
{
ShowInputDialog(Temp);
AddNote(BLOC_NOTE, NotesCount++, Temp);
}
}
在 BLOC_NOTE 的第三个元素上,程序在
Notes = (struct NOTE *) realloc(Notes, (NotesCount + 1) * sizeof(struct NOTE));
VS说我操作系统Windows启动了一个断点......
怎么了?
编辑
将代码从评论移到这里
void ShowInputDialog(NOTE * Temp)
{
printf("Name: ");
scanf("%s", (*Temp).NAME);
printf("Telephone: ");
scanf("%s", (*Temp).TELE);
printf("Birthday: ");
scanf("%d\.%d\.\%d", (*Temp).BDAY, ((*Temp).BDAY + 1), ((*Temp).BDAY + 2));
}