c语言:no such file or directory
voidInputList(MailList*num,int*n,FILE*fp){system("cls");inti,j,s=1;if((fp=fopen("mail...
void InputList(MailList *num,int *n,FILE *fp)
{
system("cls");
int i,j,s=1;
if((fp=fopen("maillist.txt","w"))==NULL)
{printf("open error!");
exit(1);
}
while(s)
{
printf("请输入有多少人:");
scanf("%d",n);
if(*n<=0){printf("\n输入错误,请重新输入!\n");s=1;}
else s=0;
}
for(j=1; j<*n+1; j++)
for(i=j-1; i<j; i++)
{
printf("\n请输入第%d位成员的姓名:",j);
scanf("%s",&num[i].name);
printf("请输入第%d位成员的单位:",j);
scanf("%s",&num[i].work);
printf("请输入第%d位成员的固定电话:",j);
scanf("%s",&num[i].tel);
printf("请输入第%d位成员的移动手机:",j);
scanf("%s",&num[i].phone);
printf("请输入第%d位成员的类别(如同事、朋友、同学、家人等):",j);
scanf("%s",&num[i].fenlei);
printf("请输入第%d位成员的email:",j);
scanf("%s",&num[i].email);
printf("请输入第%d位成员的QQ:",j);
scanf("%s",&num[i].QQ);
printf("请输入第%d位成员的地址:",j);
scanf("%s",&num[i].addr);
}
for(i=0; i<n; i++)
{
fprintf(fp,"%-5s %-5s %-10s %-12s %-4s %-20s %-10s %-4s\n",num[i].name,num[i].work,num[i].tel,num[i].phone,num[i].fenlei,num[i].email,num[i].QQ,num[i].addr);
}
fclose(fp);
printf("\n<录入完毕!>\n");
} 展开
{
system("cls");
int i,j,s=1;
if((fp=fopen("maillist.txt","w"))==NULL)
{printf("open error!");
exit(1);
}
while(s)
{
printf("请输入有多少人:");
scanf("%d",n);
if(*n<=0){printf("\n输入错误,请重新输入!\n");s=1;}
else s=0;
}
for(j=1; j<*n+1; j++)
for(i=j-1; i<j; i++)
{
printf("\n请输入第%d位成员的姓名:",j);
scanf("%s",&num[i].name);
printf("请输入第%d位成员的单位:",j);
scanf("%s",&num[i].work);
printf("请输入第%d位成员的固定电话:",j);
scanf("%s",&num[i].tel);
printf("请输入第%d位成员的移动手机:",j);
scanf("%s",&num[i].phone);
printf("请输入第%d位成员的类别(如同事、朋友、同学、家人等):",j);
scanf("%s",&num[i].fenlei);
printf("请输入第%d位成员的email:",j);
scanf("%s",&num[i].email);
printf("请输入第%d位成员的QQ:",j);
scanf("%s",&num[i].QQ);
printf("请输入第%d位成员的地址:",j);
scanf("%s",&num[i].addr);
}
for(i=0; i<n; i++)
{
fprintf(fp,"%-5s %-5s %-10s %-12s %-4s %-20s %-10s %-4s\n",num[i].name,num[i].work,num[i].tel,num[i].phone,num[i].fenlei,num[i].email,num[i].QQ,num[i].addr);
}
fclose(fp);
printf("\n<录入完毕!>\n");
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询