#include <stdio.h>
#include <fcntl.h>
#include <io.h>
#define MAX 3
struct day
{
int month;
int day1;
};
struct mydata
{
char name[20];
struct day birthday;
char telnum[20];
};
int main(void)
{
int f1,i=0,j;
char ch;
struct mydata *a[MAX],*p;
f1=open("C:\\list.bin",O_APPEND|O_WRONLY|O_BINARY);
if((f1!=-1))
{
do
{
printf("input the name:");
gets(a[i]->name);
printf("input the birthday(day):");
scanf(" %d",a[i]->birthday.day1);
printf("input the birthday(month):");
scanf(" %d",a[i]->birthday.month);
getchar();
printf("input the telphonenumber:");
gets(a[i]->telnum);
printf("still input (press n ou N to quie)?");
scanf(" %c",&ch);
getchar();
i++;
}while((ch!=78)&&(ch!=110)&&(i<MAX));
for(i=0;i<MAX-1;i++)
{
if(strcmp(a[i]->name,a[i+1]->name)>0)
{p=a[i];a[i]=a[i+1];a[i+1]=p;}
}
for(i=0;i<MAX;i++)
write(f1,&a[i],sizeof(a[i]));
close(f1);
printf("Data accepted!!\n");
}
else
printf("\nFile Opening Failure!!\n");
}
帮我看一下。我输入到DAY过后就出现系统错误。弹出该内存不能WRITTEN???
先建一个list.bin在C盘里哟~搞完这个再去看单内存。哈哈!
[此贴子已经被作者于2006-6-27 9:18:48编辑过]
人在江湖【走】,怎能不挨【刀】;为了能活【口】,唯有把己【超】!come on...