Results 1 to 3 of 3
Hi,
I'm new to c-programming.while trying to access one structure member using infix operator,i'm getting errro message:
[amit@localhost cprg]$ gcc -Wall -Werror struct.c
struct.c: In function `main':
struct.c:18: error: dereferencing ...
- 05-07-2007 #1
Accesing structure member:Error:dereferencing pointer to incomplete type
Hi,
I'm new to c-programming.while trying to access one structure member using infix operator,i'm getting errro message:
[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
- 05-07-2007 #2
got the fix : ) from a different forum.
struct man *p_man; <------- previous code
struct human *p_man=&man; <----- updated code
Thanks,
~amit
- 05-07-2007 #3
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