Thread: structs

  1. #1
    Registered User
    Join Date
    Dec 2012
    Posts
    54

    structs

    Am I somewhere wrong?

    Code:
    #include <stdio.h>
    #include <string.h>
    
    
    struct contacts
    {
        char fname[25];
        char lname[25];
    };
    
    
    typedef struct contacts cont;
    
    
    int main(int argc, const char * argv[])
    {
        cont->fname[24] = '\0';
        cont->lname[24] = '\0';
        
        fgets(cont->fname, 23, stdin);
        puts(cont->fname);
        
        return 0;
    }

  2. #2
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    Yes. cont is not an identifier ( a pointer to something ) it's a type.
    Kurt

  3. #3
    Registered User
    Join Date
    Dec 2012
    Posts
    54
    Oups.. Thanks!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 01-08-2013, 07:55 AM
  2. Typedef Structs inside Typdef structs
    By gremory in forum C Programming
    Replies: 21
    Last Post: 12-30-2011, 07:48 PM
  3. [ noob question ] Help with structs within structs
    By Riverfoot in forum C Programming
    Replies: 3
    Last Post: 04-26-2011, 07:24 PM
  4. Passing Structs Into An Array Of Structs.
    By TheTaoOfBill in forum C Programming
    Replies: 3
    Last Post: 10-07-2010, 09:38 AM
  5. passing structs & pointers to structs as arguments
    By Markallen85 in forum C Programming
    Replies: 6
    Last Post: 03-16-2004, 07:14 PM