The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
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

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 05-07-2007
amit4g's Avatar
Registered User
 

Join Date: Apr 2006
Location: Bangalore,India
Posts: 29
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
Reply With Quote
Forum Sponsor
  #2  
Old 05-07-2007
Registered User
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,397
Change
Code:
struct man *p_man;
to
Code:
struct human *p_man=&man;
Reply With Quote
  #3  
Old 05-07-2007
amit4g's Avatar
Registered User
 

Join Date: Apr 2006
Location: Bangalore,India
Posts: 29
Thanks a ton anbu23 : )
Reply With Quote
  #4  
Old 05-07-2007
amit4g's Avatar
Registered User
 

Join Date: Apr 2006
Location: Bangalore,India
Posts: 29
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 : )
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 07:14 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0