A pointer problem

This is a discussion on A pointer problem within the C Programming forums, part of the General Programming Boards category; Code: #include<stdio.h> struct student { char first[10]; char last[10]; int year; }; int main() { struct student stud; struct studnet ...

  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, 09:53 PM
  2. Another pointer problem
    By mikahell in forum C++ Programming
    Replies: 21
    Last Post: 07-20-2006, 08:37 PM
  3. Pointer problem
    By mikahell in forum C++ Programming
    Replies: 5
    Last Post: 07-20-2006, 11:21 AM
  4. Quick question about SIGSEGV
    By Cikotic in forum C Programming
    Replies: 30
    Last Post: 07-01-2004, 08:48 PM
  5. pointer problem
    By DMaxJ in forum C Programming
    Replies: 4
    Last Post: 06-11-2003, 01:14 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21