c语言结构体指针,为什么在vc6编译会出错
本帖最后由 d173220523 于 2020-4-12 21:20 编辑#include<stdio.h>
struct Student
{
int x;
int y;
};
int main()
{
Student**** s;
s = (Student****)100;
s++; //s的值是多少?
s = s+2; //s的值是多少?
s = s-3; //s的值是多少?
}
--------------------Configuration: bvcb - Win32 Debug--------------------
Compiling...
bvcb.c
D:\bvcb.c(9) : error C2065: 'Student' : undeclared identifier
D:\bvcb.c(9) : error C2065: 's' : undeclared identifier
D:\bvcb.c(9) : error C2100: illegal indirection
D:\bvcb.c(9) : error C2100: illegal indirection
D:\bvcb.c(9) : error C2100: illegal indirection
D:\bvcb.c(9) : warning C4552: '*' : operator has no effect; expected operator with side-effect
D:\bvcb.c(10) : error C2059: syntax error : ')'
执行 cl.exe 时出错.
bvcb.exe - 1 error(s), 0 warning(s)
不知道你定义了x,y用来干嘛的,主函数里也没有实例化 这是谭浩强的题目吗
typedef struct _Student
{
int x;
int y;
}Student, *PStudent;
int main()
{
Student**** s;
s = (Student****)100;
s++; //s的值是多少?
s = s + 2; //s的值是多少?
s = s - 3; //s的值是多少?
} 加上 struct Student**** s; C语言不加typedef 进行声明,或使用时不加struct 进行修饰当然报错,而.cpp 也就是vs以c++编译则可以直接使用不报错。 为什么要用vc6,vs多好用啊 又是滴水的神操作:lol
页:
[1]