![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| pointer to structure example pls | user_prady | High Level Programming | 1 | 02-19-2008 04:24 AM |
| variables usage without dereferencing | ag79 | Shell Programming and Scripting | 1 | 02-06-2008 08:26 AM |
| error: field has incomplete type | boyanov | High Level Programming | 4 | 08-10-2007 01:15 AM |
| array type has incomplete element type | jaganadh | High Level Programming | 1 | 07-24-2007 12:54 AM |
| Unknown File Type error | rohitsz | SUN Solaris | 3 | 07-15-2007 02:57 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
||||
|
||||
|
Accesing structure member:Error:dereferencing pointer to incomplete type
[amit@localhost cprg]$ gcc -Wall -Werror struct.c
struct.c: In function `main': struct.c:18: error: dereferencing pointer to incomplete type [amit@localhost cprg]$ cat struct.c #include <stdio.h> #include <stdlib.h> #include <string.h> /*Declaration of structure*/ struct human { char *first; char gender[10]; int age; } man, *p_human; struct man *p_man; int main(void) { strcpy(man.gender,"Male"); printf("%s\n",man.gender); printf("%s\n",p_man->gender); <---------- exit(EXIT_SUCCESS); } The "p_man" is pointer to structure "man".what am i missing here. Thanks, ~amit |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Change
Code:
struct man *p_man; Code:
struct human *p_man=&man; |
|
#3
|
||||
|
||||
|
Thanks a ton anbu23 : )
|
|
#4
|
||||
|
||||
|
sheer stupidity by me .(My applogy)
declared a structure pointer and never assigned it to anything(should have assigned it to structure). Anyways,Better late than never : ) |
||||
| Google The UNIX and Linux Forums |
| Thread Tools | |
| Display Modes | |
|
|