Thread: A pointer problem

  1. #1
    Registered User
    Join Date
    Apr 2005
    Posts
    67

    A pointer problem

    Code:
    #include<stdio.h>
    
    struct student {
      
      char first[10];
      char last[10];
      int year;
    };
    
    int main() {
      struct student stud;
      struct studnet *pstud;
      
      strcpy(stud.first,"Mike");
      strcpy(stud.last,"Dike");
     stud.year=1;
     pstud=&stud;
      printf("%s  %s   %d year!\n",pstud->first,pstud->last,pstud->year);
      return 0;
    }
    Im just learning pointers and structs. I get this error:
    Code:
    error: dereferencing pointer to incomplete type
    pointers.c:18: error: dereferencing pointer to incomplete type
    pointers.c:18: error: dereferencing pointer to incomplete type
    line 18 is the printf statement.

    Thanks for helping!

  2. #2
    Registered User
    Join Date
    May 2005
    Posts
    4
    struct student stud;
    struct studnet *pstud;

    in the second line it should be "struct student *pstud".
    its student spelling mistake .!! correct it.

    regards
    Ravi

  3. #3
    Registered User
    Join Date
    Apr 2005
    Posts
    67
    ou, thanks! Damn typos

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. pointer to pointer realloc problem
    By prakash0104 in forum C Programming
    Replies: 14
    Last Post: 04-06-2009, 08:53 PM
  2. Another pointer problem
    By mikahell in forum C++ Programming
    Replies: 21
    Last Post: 07-20-2006, 07:37 PM
  3. Pointer problem
    By mikahell in forum C++ Programming
    Replies: 5
    Last Post: 07-20-2006, 10:21 AM
  4. Quick question about SIGSEGV
    By Cikotic in forum C Programming
    Replies: 30
    Last Post: 07-01-2004, 07:48 PM
  5. pointer problem
    By DMaxJ in forum C Programming
    Replies: 4
    Last Post: 06-11-2003, 12:14 PM