H5游戏论坛

 找回密码
 入驻H5
查看: 689|回复: 2

[求助] 各位帮帮忙

 关闭 [复制链接]

大湿 - 大湿

发表于 2012-9-21 16:25:55 | 显示全部楼层 |阅读模式
30H币
不知道是我的软件问题,还是我的学的不到家.些个简单的程序没事.但是写个稍微复杂一点的总是报错,.我今天写了两个很多语言的程序.都报错,.
但是些简单就没有报错。我估计是我写错了,但是我又不知道,错在哪里?谁帮看看   真心求教,.感激不尽


这是第一个:
# include<stdio.h>
# include<string.h>

struct student
{     int age;
       char **;
       char name[100];
};
void inpustudent (struct student stu)
int main(void)
{   
    struct student st;
  
    inpustudent(st);   
   //OutputsStudent();
   
   printf("%d %c %s",st.age, st.**, st,name);
   return 0;
}

void inpustudent (struct student stu)
{
       stu.age = 10;
       stu.** = 'F';
       strcpy(stu.name,"张三");
}


有爱就有H5~

大湿 - 大湿

 楼主| 发表于 2012-9-21 16:26:23 | 显示全部楼层
这是第二个:
# include<stdio.h>
# include<malloc.h>

struct student
{
   int age;
   float score;
   char name[100];
};

main(void)

{
   int len;
   int * parr;
   int i;
   
   
   printf("请输入学生的个数:\n");
   printf("len = ");
   scanf("%d",&len);

   parr = (struct student *)malloc(len * sizerof(struct student));

   for (i=0; i<len; ++i)
   {
      printf("请输入第%d个学生的信息: ", i+1);
      printf("age = ");
      scanf("%d", &parr[i]);
      printf("name = ",);
      scanf("%s", parr[i].name);
      printf("score = ");
      scanf("%f",&parr[i].score);
     }

   //排序
  for (i=0; i<len; ++i)
  {
   for (j=0; j<len-1-i; ++j)
   {
     if (parr[i].score > parr[j+1].score)
     {
          t = parr[j];
          parr[j] = parr[j+1];
           parr[j+1] = t;
     }
   }
  }
   //输出
   for (i=0;i<len;++i)
   {
      printf("第%d学生的信息是:\n ", i+1);
     
      printf("age = %d\n", parr[i].age);
     
      printf("name = %s\n", parr[i].name);
     
      printf("score =  %f\n",parr[i].score);
     
      printf("\n");
   }
            return 0;
}
有爱就有H5~
回复

使用道具 举报

大湿 - 大湿

 楼主| 发表于 2012-9-21 17:06:14 | 显示全部楼层
C:\Documents and Settings\Administrator\×桌面\C\20_3.cpp(15) : error C2146: syntax error : missing ';' before identifier 'student'
C:\Documents and Settings\Administrator\×桌面\C\20_3.cpp(15) : warning C4551: function call missing argument list
C:\Documents and Settings\Administrator\×桌面\C\20_3.cpp(15) : error C2065: 'parr' : undeclared identifier
C:\Documents and Settings\Administrator\×桌面\C\20_3.cpp(15) : error C2275: 'student' : illegal use of this type as an expression
        C:\Documents and Settings\Administrator\×桌面\C\20_3.cpp(5) : see declaration of 'student'
C:\Documents and Settings\Administrator\×桌面\C\20_3.cpp(23) : error C2440: '=' : cannot convert from 'struct student *' to 'int'
        This conversion requires a reinterpret_cast, a C-style cast or function-style cast
C:\Documents and Settings\Administrator\×桌面\C\20_3.cpp(29) : error C2109: subscript requires array or pointer type
C:\Documents and Settings\Administrator\×桌面\C\20_3.cpp(29) : error C2228: left of '.age' must have class/struct/union type
C:\Documents and Settings\Administrator\×桌面\C\20_3.cpp(31) : error C2109: subscript requires array or pointer type
C:\Documents and Settings\Administrator\×桌面\C\20_3.cpp(31) : error C2228: left of '.name' must have class/struct/union type
C:\Documents and Settings\Administrator\×桌面\C\20_3.cpp(33) : error C2109: subscript requires array or pointer type
C:\Documents and Settings\Administrator\×桌面\C\20_3.cpp(33) : error C2228: left of '.score' must have class/struct/union type
C:\Documents and Settings\Administrator\×桌面\C\20_3.cpp(39) : error C2065: 'j' : undeclared identifier
C:\Documents and Settings\Administrator\×桌面\C\20_3.cpp(41) : error C2109: subscript requires array or pointer type
C:\Documents and Settings\Administrator\×桌面\C\20_3.cpp(41) : error C2228: left of '.score' must have class/struct/union type
C:\Documents and Settings\Administrator\×桌面\C\20_3.cpp(41) : error C2109: subscript requires array or pointer type
C:\Documents and Settings\Administrator\×桌面\C\20_3.cpp(41) : error C2228: left of '.score' must have class/struct/union type
C:\Documents and Settings\Administrator\×桌面\C\20_3.cpp(43) : error C2065: 't' : undeclared identifier
C:\Documents and Settings\Administrator\×桌面\C\20_3.cpp(43) : error C2109: subscript requires array or pointer type
C:\Documents and Settings\Administrator\×桌面\C\20_3.cpp(44) : error C2109: subscript requires array or pointer type
C:\Documents and Settings\Administrator\×桌面\C\20_3.cpp(44) : error C2109: subscript requires array or pointer type
C:\Documents and Settings\Administrator\×桌面\C\20_3.cpp(44) : error C2106: '=' : left operand must be l-value
C:\Documents and Settings\Administrator\×桌面\C\20_3.cpp(45) : error C2109: subscript requires array or pointer type
C:\Documents and Settings\Administrator\×桌面\C\20_3.cpp(45) : error C2106: '=' : left operand must be l-value
C:\Documents and Settings\Administrator\×桌面\C\20_3.cpp(54) : error C2109: subscript requires array or pointer type
C:\Documents and Settings\Administrator\×桌面\C\20_3.cpp(54) : error C2228: left of '.age' must have class/struct/union type
C:\Documents and Settings\Administrator\×桌面\C\20_3.cpp(56) : error C2109: subscript requires array or pointer type
C:\Documents and Settings\Administrator\×桌面\C\20_3.cpp(56) : error C2228: left of '.name' must have class/struct/union type
C:\Documents and Settings\Administrator\×桌面\C\20_3.cpp(58) : error C2109: subscript requires array or pointer type
C:\Documents and Settings\Administrator\×桌面\C\20_3.cpp(58) : error C2228: left of '.score' must have class/struct/union type
执行cl.exe 时出错.
有爱就有H5~
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 入驻H5

本版积分规则

Archiver|手机版|小黑屋|免责声明|H5Gal游戏论坛 |网站地图|网站地图

GMT+8, 2025-5-7 09:49 , Processed in 0.017353 second(s), 7 queries , Gzip On, Redis On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表