
C++数组赋值不成功
voidinputStudentValue(STUDENT*ps){intscore;charsex;charname[20];charphone[15];printf(...
void inputStudentValue(STUDENT *ps)
{
int score;
char sex;
char name[20];
char phone[15];
printf("Name:");//加上提示,方便用户操作
scanf("%s",name);
getchar();
printf("Sex:");
scanf("%c",&sex);
printf("Score:");
scanf("%d",&score);
printf("Phone:");
scanf("%s",phone);
//将变量所得到的值,再赋给ps所指向的STUDENT变量
setStudentValue(ps,score,name,sex,phone);
}
void inputStudentValue(STUDENT *ps)
{
int score;
char sex;
char name[20];
char phone[15];
printf("Name:");//加上提示,方便用户操作
scanf("%s",name);
getchar();
printf("Sex:");
scanf("%c",&sex);
printf("Score:");
scanf("%d",&score);
printf("Phone:");
scanf("%s",phone);
//将变量所得到的值,再赋给ps所指向的STUDENT变量
setStudentValue(ps,score,name,sex,phone);
}
编程序,定义一个STUDENT类型的数组,该数组有10个
元素,给这10个元素分别赋值
STUDENT xuesheng[10];
for(i=1;i<=10;i++)
{
inputStudentValue(xuesheng[i]);
}
出现了赋值错误。 incompatible type for argument 1 of `inputStudentValue'
小弟请大虾指点。 错了那要怎么写? 展开
{
int score;
char sex;
char name[20];
char phone[15];
printf("Name:");//加上提示,方便用户操作
scanf("%s",name);
getchar();
printf("Sex:");
scanf("%c",&sex);
printf("Score:");
scanf("%d",&score);
printf("Phone:");
scanf("%s",phone);
//将变量所得到的值,再赋给ps所指向的STUDENT变量
setStudentValue(ps,score,name,sex,phone);
}
void inputStudentValue(STUDENT *ps)
{
int score;
char sex;
char name[20];
char phone[15];
printf("Name:");//加上提示,方便用户操作
scanf("%s",name);
getchar();
printf("Sex:");
scanf("%c",&sex);
printf("Score:");
scanf("%d",&score);
printf("Phone:");
scanf("%s",phone);
//将变量所得到的值,再赋给ps所指向的STUDENT变量
setStudentValue(ps,score,name,sex,phone);
}
编程序,定义一个STUDENT类型的数组,该数组有10个
元素,给这10个元素分别赋值
STUDENT xuesheng[10];
for(i=1;i<=10;i++)
{
inputStudentValue(xuesheng[i]);
}
出现了赋值错误。 incompatible type for argument 1 of `inputStudentValue'
小弟请大虾指点。 错了那要怎么写? 展开
1个回答
展开全部
直接传xuesheng看看 接着 下面加句xuesheng++看看
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询