c语言字符数组成绩统计问题,C语言问题 使用字符数组和实型数组分别存储学生姓名和成绩,并通过对学生成绩的排序,按名次输出姓名成绩...

我只学到数组和基础的内容,未学结构体。

程序已经写好,也通过编译,但对于编译器的Warning信息,我不知如何修改,望指点。

我主要用冒泡排序,并在对成绩排序的同时也对名字排序。

#include

#include

int main()

{

char* Name[100][20],cTemp[20];

float mark[100],fTemp;

int i,j,iNum;

puts("请输入学生数");

scanf("%d",&iNum);

puts("请分别输入姓名和成绩");

for(i=0;i

{

scanf("%s",&Name[i]);

scanf("%f",&mark[i]);

}

for(i=1;i

{

for(j=iNum-1;j>=i;j--)

{

if(mark[j]>mark[j-1])

{

fTemp=mark[j-1]; //交换成绩

mark[j-1]=mark[j];

mark[j]=fTemp;

strcpy(cTemp,Name[j-1]); //交换姓名

strcpy(Name[j-1],Name[j]);

strcpy(Name[j],cTemp);

}

}

}

printf("名次\t姓名\t成绩:\n");

for(i=0;i

{

printf("%d\t%s\t%f\n",i+1,Name[i],mark[i]);

}

return 0;

}

这是编译器的提示:

In function 'main':

(行 列)

28 5 [Warning] passing argument 2 of 'strcpy' from incompatible pointer type [enabled by default]

2 0 In file included from G:\范例\8.9.2.c

51 18 c:\program files\dev-cpp\mingw64\x86_64-w64-mingw32\include\string.h [Note] expected 'const char * __restrict__' but argument is of type 'char **'

29 5 [Warning] passing argument 1 of 'strcpy' from incompatible pointer type [enabled by default]

2 0 In file included from G:\范例\8.9.2.c

51 18 c:\program files\dev-cpp\mingw64\x86_64-w64-mingw32\include\string.h [Note] expected 'char * __restrict__' but argument is of type 'char **'

29 5 [Warning] passing argument 2 of 'strcpy' from incompatible pointer type [enabled by default]

2 0 In file included from G:\范例\8.9.2.c

51 18 c:\program files\dev-cpp\mingw64\x86_64-w64-mingw32\include\string.h [Note] expected 'const char * __restrict__' but argument is of type 'char **'

30 5 [Warning] passing argument 1 of 'strcpy' from incompatible pointer type [enabled by default]

2 0 In file included from G:\范例\8.9.2.c

51 18 c:\program files\dev-cpp\mingw64\x86_64-w64-mingw32\include\string.h [Note] expected 'char * __restrict__' but argument is of type 'char **'

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值