typeDef

P

Priya Mishra

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 *Type,
char *file_Name);



int main(int argc, char **argv )
{

int error;
structure *str;


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

return error;
}
 
F

Flash Gordon

Priya said:
What is wrong in the below code,
I get the 2 error when i compile the prog... what is mean ??

It means that you have not posted code that exhibits the problem you are
describing.
error C2275: structure: illegal use of this type as an expression

This error does not match the problems in you code, therefore was
probably caused by something you have not posted.
error C2065: str: undeclared identifier

This error was probably a knock on effect of the first error.
typedef struct
{
char file;
int a;
int b;
int c;

} structure;

Very bad naming, use names that actually mean something.
int func(structure *Type,
char *file_Name);

Even worse naming.
int main(int argc, char **argv )
{

int error;
structure *str;


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

This is an error, but not the one your compiler is complaining about.
You have declared str as being a pointer to structure which is what func
expects, but you are passing the address of it.
return error;
}

In future, please ensure the code you post actually exhibits the problem
you are asking about. Also, if the problem is a compiler diagnostic tell
us which line of code it is complaining about.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,470
Messages
2,571,809
Members
48,797
Latest member
PeterSimpson
Top