各位帮帮忙
不知道是我的软件问题,还是我的学的不到家.些个简单的程序没事.但是写个稍微复杂一点的总是报错,.我今天写了两个很多语言的程序.都报错,.但是些简单就没有报错。我估计是我写错了,但是我又不知道,错在哪里?谁帮看看 真心求教,.感激不尽
这是第一个:
# include<stdio.h>
# include<string.h>
struct student
{ int age;
char **;
char name;
};
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,"张三");
}
这是第二个:
# include<stdio.h>
# include<malloc.h>
struct student
{
int age;
float score;
char name;
};
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);
printf("name = ",);
scanf("%s", parr.name);
printf("score = ");
scanf("%f",&parr.score);
}
//排序
for (i=0; i<len; ++i)
{
for (j=0; j<len-1-i; ++j)
{
if (parr.score > parr.score)
{
t = parr;
parr = parr;
parr = t;
}
}
}
//输出
for (i=0;i<len;++i)
{
printf("第%d学生的信息是:\n ", i+1);
printf("age = %d\n", parr.age);
printf("name = %s\n", parr.name);
printf("score =%f\n",parr.score);
printf("\n");
}
return 0;
} 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 时出错.
页:
[1]