Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > typeDef

Reply
Thread Tools

typeDef

 
 
Priya Mishra
Guest
Posts: n/a
 
      07-13-2005
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;
}

 
Reply With Quote
 
 
 
 
Flash Gordon
Guest
Posts: n/a
 
      07-13-2005
Priya Mishra wrote:
> 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.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
CRTP-problem: How can the base class typedef a derived class' typedef? oor C++ 0 05-20-2008 12:39 PM
java needs typedef Steve Green Java 11 03-25-2005 09:52 AM
Typedef of a template? Richard van Wegen C++ 3 07-15-2003 07:22 AM
template typedef as return type Robert A. T. Kaldy C++ 1 07-09-2003 06:25 PM
typedef enum qazmlp C++ 2 07-02-2003 11:55 AM



Advertisments