论坛: 编程破解 标题: 大伙看看,哪儿错了? 复制本贴地址    
作者: free [free]    论坛用户   登录
struct student
{  char num[3];
   char name[4];
   int score;
}stu[3];

void main()
{
   struct student *p;
   int i;
   p=stu;
   for(i=0;i<3;i++,p++)
    {
     scanf("%c%c%d",p->num,p->name,p->score);
     printf("\n");
    }
   p=stu;
   printf("学号 姓名 成绩\n");
   for(i=0;i<3;i++,p++)
     printf("%c %c %d\n",p->num,p->name,p->score);
}

编译通过,可就是得不到预期效果。
还有,把score设为float型,在输入第一行时就出现:
 scanf :floating point formats not linked  
Abnormal program termination
我是E盲,各位,是什么意思啊?


地主 发表时间: 01/17 01:11

回复: quake [quake]   论坛用户   登录
scanf("%c%c%d",p->num,p->name,p->score);

scanf("%s%s%d",p->num,p->name,p->score);

B1层 发表时间: 01/20 22:58

回复: free [free]   论坛用户   登录
谢谢!
我改了,输入没有问题了。可是输出的结果好像还有错误。

B2层 发表时间: 01/21 23:07

回复: steaven [steaven]   论坛用户   登录
printf("%c %c %d\n",p->num,p->name,p->score);

printf("%s %s %d\n",p->num,p->name,p->score);


这个也要改咯~!~!

是字符串,不是单个字符啊



B3层 发表时间: 03/23 20:28

回复: 286 [unique]   版主   登录
////////////////////////////////////
scanf("%c%c%d",p->num,p->name,p->score);
printf("\n");
////////////////////
改成:
////////////////////////
scanf("%c,%c,%d",p->num,p->name,p->score);
///////////////////////

B4层 发表时间: 03/24 12:57

论坛: 编程破解

20CN网络安全小组版权所有
Copyright © 2000-2010 20CN Security Group. All Rights Reserved.
论坛程序编写:NetDemon

粤ICP备05087286号