C语言 怎样把二维字符串数组复制给一维字符串数组

下面的strcpy(),使用不成功!求高手帮忙!代码:#include<stdio.h>#include<stdlib.h>structstudent{charNum[2... 下面的strcpy(),使用不成功!
求高手帮忙!
代码:#include<stdio.h>
#include<stdlib.h>
struct student
{
char Num[20];
char Nam[20];
char Dep[20];
char Sub[20];
char Brip[20];
char Address[100];
char Pnum[20];
struct student *next;
};
main()
{
struct student *p;
FILE *fp;
int a,i,j,c;
char b[7][20];
fp=fopen("D:通讯录.txt","rt");
if(fp==NULL)
{
printf("文件打开失败\n");
exit(0);
}
fscanf(fp,"%d",&c);
for(i=0;i<=6;i++)
{
for(j=0;;j++)
{
a=fgetc(fp);
if(a!=10)
b[i][j]=a;
else
{
b[i][j]='\0';
break;
}
}
}
printf("%d",c);
for(i=0;i<=6;i++)
{
printf("%s\n",b[i]);
}
strcpy(p->Num,b[0]);
strcpy(p->Nam,b[1]);
strcpy(p->Dep,b[2]);
strcpy(p->Sub,b[3]);
strcpy(p->Brip,b[4]);
strcpy(p->Address,b[5]);
strcpy(p->Pnum,b[6]);
printf("%s\n%s\n%s\n%s\n%s\n%s\n%s\n",p->Num,p->Nam,p->Dep,p->Sub,p->Brip,p->Address,p->Pnum);
}
展开
 我来答
百度网友4fee1d0
2010-07-26 · TA获得超过341个赞
知道小有建树答主
回答量:411
采纳率:0%
帮助的人:281万
展开全部
strcpy所在的头文件没有加载,开头加上#include <string.h>
就ok了。
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式