?
Solved

dereferencing pointer to incomplete type.

Posted on 2003-02-26
7
Medium Priority
?
705 Views
Last Modified: 2010-04-15
hi,

i've a structure as

struct info{
          int id;
       char name[20];
       int port;
        req[8];
        };
int noreq,pno; //i've some values both of them between1-8
 
and i've a pointer 'p' defined  as : struct info *p;
when iam giving as p->req[pno] > noreq;

at this line its throwing compilation error as dereferencing pointer to incomplete type.why?

thanks.
0
Comment
Question by:haisai54
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 8026939
>>why?

Because the 'req' member of the struct has no data type. If it e.g. was a char array, you'd write

struct info{
      int id;
      char name[20];
      int port;
      char req[8];
       };

(substitute that with the actual type)
0
 
LVL 6

Expert Comment

by:gj62
ID: 8026940
What is req?

In your structure definition, you have no type associated with req:

struct info{
         int id;
         char name[20];
         int port;
         ???  req[8];
       };

I would assume it would be char, or an array of ints?
0
 

Accepted Solution

by:
vijay_rangaraj earned 300 total points
ID: 8031111
The error is because you have not specified any data type associated with req. If there is no datatype, the compiler does not know how to proceed with the operators.

 As you have compared req with noreq, which is an int, you can also make req as int( or to char if req has values from -128 to +127).

struct info{
         int id;
      char name[20];
      int port;
      int req[8];      <-------------
       };


Good luck.
-- Vijay

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 8

Expert Comment

by:ssnkumar
ID: 8032396
How can it give "Incomplete Type" error!?
It has to give the error for struct definition itself.....
Why it didn't give error for struct info:req itself!?

-Narendra
0
 
LVL 86

Expert Comment

by:jkr
ID: 8035888
Err, isn't that accepted answer the same what I posted 12h earlier?
0
 
LVL 6

Expert Comment

by:gj62
ID: 8035917
haisai - you should accept the FIRST answer (I posted mine at almost the same time and had not seen jkr's post yet).  Also, why the 'B' and not an 'A' - I don't see how more info could have been provided...

Vijay - you should not post identical answers if you see an existing answer - you really didn't clarify anything...

jkr - look at the bright side, the answer received only a 'B', though it looked like it was a complete answer to me... <grin>
0
 
LVL 86

Expert Comment

by:jkr
ID: 8036074
:o)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question