Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

dereferencing pointer to incomplete type.

Posted on 2003-02-26
7
Medium Priority
?
714 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
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
Suggested Courses

578 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