正确的Typedef [英] Correct Typedef

查看:77
本文介绍了正确的Typedef的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面的代码有什么问题,

我编译prog时得到2错误...是什么意思?

错误C2275:结构:非法使用此类型作为表达式

错误C2065:str:未声明的标识符

typedef struct

{

char文件;

int a;

int b;

int c;


}结构;

int func(结构* Ob,

char * fileName);


int main(int argc,char ** argv)

{

int error;

structure * str;

error = func(& str, " abc.txt");

返回错误;

}


谢谢

Priya

What is wrong in the below code,
I get the 2 error when i compile the prog... what is mean ??
error C2275: structure: illegal use of this type as an expression
error C2065: str: undeclared identifier
typedef struct
{
char file;
int a;
int b;
int c;

} structure;
int func(structure *Ob,
char *fileName);

int main(int argc, char **argv )
{
int error;
structure *str;
error = func(&str, "abc.txt");
return error;
}

Thanks
Priya

推荐答案

Priya Mishra写道:
Priya Mishra wrote:
以下代码有什么问题,
我当我编译prog时得到2错误...是什么意思??

错误C2275:结构:非法使用此类型作为表达式
er ror C2065:str:未声明的标识符
这是否意味着您使用的是VC ++?请使用C编译器,好吗?
#include< stdio.h>
typedef struct
{char文件;
int a;
int b;
int c ;

}结构;
一个没有标签的结构,并且在C编译器上可以使用typedef''ing。

int func(结构* Ob,
char * fileName);

int main(int argc,char ** argv)
不需要argc& argv如果你不打算使用它们,那么

int main(void)有效。 {

int error;
structure * str;
恕我直言,你试图检索一些信息

关于某个文件(假设函数声明是理智的。)

你肯定需要在这里分配一些内存吗? br />
或者,至少是一个有效的指针。

错误= func(& str," abc.txt");
错误:func将指针指向struct,str,是指向

struct的指针。

返回错误;
}
What is wrong in the below code,
I get the 2 error when i compile the prog... what is mean ??
error C2275: structure: illegal use of this type as an expression
error C2065: str: undeclared identifier Does that mean you are using VC++? Use a C compiler, will you, please? #include <stdio.h>
typedef struct
{
char file;
int a;
int b;
int c;

} structure; A struct without a tag, and typedef''ing is okay on C compilers.

int func(structure *Ob,
char *fileName);

int main(int argc, char **argv ) Don''t need the argc & argv if you are not going to use them, so
int main(void) works. {
int error;
structure *str; IMHO, you are trying to retrieve some information
about some file (assuming the function declaration is sane.)
Surely you need some memory allocated here?
Or, atleast a valid pointer.

error = func(&str, "abc.txt"); err: func takes pointer to struct, str, is a pointer to pointer to
struct.

return error;
}









Priya Mishra写道:


Priya Mishra wrote:
以下代码有什么问题,当我编译prog时我得到2错误...是什么意思??

错误C2275:结构:非法使用此类型作为表达式
错误C2065 :str:未声明的标识符
What is wrong in the below code,
I get the 2 error when i compile the prog... what is mean ??
error C2275: structure: illegal use of this type as an expression
error C2065: str: undeclared identifier



FYI:

复制粘贴MSVC ++中的代码6

我没有得到这样的错误,我得到的是其他一些错误,

在你向func传递错误的参数时。所以也许你可以解释

a更多关于这是否是你试过的唯一一段代码

编译或不...

[snip ]


FYI:
On copy-pasting the code in MSVC++ 6
I did not get such an error, what I got was some other error,
in your passing a wrong argument to func. So maybe you can explain
a bit more about whether this is the only piece of code you tried
compiling or not...
[snip]




Priya Mishra写道:


Priya Mishra wrote:
下面有什么问题代码,
当我编译prog时我得到2错误...是什么意思??

错误C2275:结构:非法使用此类型作为表达式
错误C2065:str:未声明的标识符

typedef struct
{char文件;
int a;
int b;
int c;

}结构;

int func(结构* Ob,
char * fileName);

int main(int argc,char * * argv)

int error;
structure * str;

error = func(& str," abc.txt") ;

返回错误;
}
谢谢
Priya
What is wrong in the below code,
I get the 2 error when i compile the prog... what is mean ??
error C2275: structure: illegal use of this type as an expression
error C2065: str: undeclared identifier
typedef struct
{
char file;
int a;
int b;
int c;

} structure;
int func(structure *Ob,
char *fileName);

int main(int argc, char **argv )
{
int error;
structure *str;
error = func(&str, "abc.txt");
return error;
}

Thanks
Priya




如果我是没错,有另一个线程完全相同

的内容,

海报的名字等等.netnet不是速溶咖啡,给它一些时间
重新创建

a线程。您的线程可能会丢失,但这是一个罕见的。我已经

回复了另一个,找到相同内容确实令人恼火

elsethread。



If I am not too wrong, there was another thread with the exact same
content,
poster''s name etc. Usenet is not instant coffee, give it some time
before recreating
a thread. It is possible that your thread gets lost, but that is a
rarety. I have already
replied to the other, and it is indeed irritating to find same content
elsethread.

这篇关于正确的Typedef的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆