求一道c语言题 把答案上传一下 谢谢了 (程序名:A_01.CPP)

(程序名:A_01.CPP)
以下主程序定义了一个结构体数组,并赋初值,以name中存储#作为结束标志.
1.函数print_txl的作用是输出结构体数组的信息,但其中有错误,请改正.(只修改print_txl函数部分)
2.编写一个输入函数void input_txl(struct TXJL p[]),其作用是可以给结构体数组输入多项数据(手机号码的前3位存在firstNum,后8位存在secondNum),且保持以name中存储#作为结束标志的特点.(调试时将主程序中的被注释掉的两行恢复即可)
3.编写一个输出函数void write_txl(struct TXJL p[],char * pFileName),其作用是将结构体数组写入指定的文件中,要求先写入"#"所在行的下标和换行符,再用循环写入结构体数组的每一项数据,格式与print函数中一样.(调试时将主程序中的被注释掉的最后一行恢复即可)
#include <stdio.h>
#include <string.h>
#define MAX 100
struct PHONE
{
int firstNum;
int secondNum;
};
struct TXJL
{
char name[10];
struct PHONE phone ;
};
void print_txl(struct TXJL p[])
{
int i=0;
for (i=0;i<MAX;i++)
{
if (strcmp(p[i].name="#") continue;
printf("姓名:%12s 手机:%d%08d\n",p[i].name[],p[i].phone.firstNum,p[i].phone.secondNum);
}
}
main()
{
struct TXJL a[MAX]={{"Li",{130,12345678}},{"Zhang",{139,78}},{"Wang",{131,12345678}},{"Zhao",{138,12345678}},{"#",{0,0}}};
print_txl(a);
// input_txl(a);
// print_txl(a);
// write_txl(a,"D:\\TXJL.TXT");
}

#include <stdio.h>
#include <string.h>
#define MAX 100
struct PHONE
{
int firstNum;
int secondNum;
};
struct TXJL
{
char name[10];
struct PHONE phone ;
};
void print_txl(struct TXJL p[])
{
int i=0;//这里的分号";"应该是英文状态下的,改掉
for (i=0;i<MAX;i++)
{
if (strcmp(p[i].name,"#") == 0) break;//这里字符串比较代码错误,相等的字符串strcmp返回0,还有当name=="#'时不是continue而是break跳出
printf("姓名:%12s   手机:%d%08d\n",p[i].name,p[i].phone.firstNum,p[i].phone.secondNum);//name后面的[]去掉
}
}
void input_txl(struct TXJL p[])//新增加的input_txl函数
{
int i = 0 ;
printf("输入姓名 电话号码,结束输入\"#\":\n") ;
do{
scanf("%s", p[i].name) ;
if(strcmp(p[i].name, "#") == 0)
break ;
scanf("%3d%8d", &p[i].phone.firstNum, &p[i].phone.secondNum) ;
i++ ;
}while(1) ;
}
void write_txl(struct TXJL p[], char * pFileName)//新增加的write_txl函数
{
FILE* pFile ;
inti ;
if((pFile=fopen(pFileName, "w+")) == NULL)
{
printf("文件打开失败!") ;
return ;
}
fprintf(pFile, "\r\n") ;//写入换行符
for(i = 0; i < MAX; i++)
{if (strcmp(p[i].name,"#") == 0) break;
fprintf(pFile, "姓名:%12s   手机:%d%08d\n",p[i].name,p[i].phone.firstNum,p[i].phone.secondNum) ;
}
//回溯到文件开头写入"#"所在的下标
rewind(pFile) ;
fprintf(pFile, "%d", i) ;
fclose(pFile) ;
}
main()
{
struct TXJL a[MAX]={{"Li",{130,12345678}},{"Zhang",{139,78}},{"Wang",{131,12345678}},{"Zhao",{138,12345678}},{"#",{0,0}}};
//print_txl(a);
//input_txl(a);
//print_txl(a);
//write_txl(a,"D:\\TXJL.TXT");
}

温馨提示:答案为网友推荐,仅供参考