c语言,以下代码怎么改正'strcpy' : cannot convert parameter 1 from 'int' to 'char *'...
#include<stdio.h>#include<string.h>#include<stdlib.h>voidmain(){//定义结构体structLuYou{ch...
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void main()
{
//定义结构体
struct LuYou{
char aim[10];
int dist;
char next;
}old[4]={{"N1",5,'A'},
{"N2",3,'C'},
{"N6",6,'F'},
{"N8",4,'E'},
};
struct LuYou New[5];
//这段代码粗线错误
for(int i=0;i<5;i++)
{
strcpy(New[i].aim,old[i].aim);
strcpy(New[i].dist,old[i].dist);
strcpy(New[i].next,old[i].next);
}
for(i=0;i<5;i++)
{
printf("%c",New[i].aim);
printf("%d",New[i].aim);
printf("%c",New[i].aim);
}
} 展开
#include <string.h>
#include <stdlib.h>
void main()
{
//定义结构体
struct LuYou{
char aim[10];
int dist;
char next;
}old[4]={{"N1",5,'A'},
{"N2",3,'C'},
{"N6",6,'F'},
{"N8",4,'E'},
};
struct LuYou New[5];
//这段代码粗线错误
for(int i=0;i<5;i++)
{
strcpy(New[i].aim,old[i].aim);
strcpy(New[i].dist,old[i].dist);
strcpy(New[i].next,old[i].next);
}
for(i=0;i<5;i++)
{
printf("%c",New[i].aim);
printf("%d",New[i].aim);
printf("%c",New[i].aim);
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询