Table of structures

This is a discussion on Table of structures within the C Programming forums, part of the General Programming Boards category; Why line 9 (struct plant table[50]; ) causes error in WinAVR-GCC compiler ( two or more data types in declaration ...

  1. #1
    Registered User
    Join Date
    Nov 2008
    Location
    Chotomów (near Legionowo), POLAND
    Posts
    2

    Unhappy Table of structures

    Why line 9 (struct plant table[50]; ) causes error in WinAVR-GCC compiler (two or more data types in declaration specyfiers):
    Code:
    #include <stdio.h> //printf, puts, scantf
    struct plant 
        {
            char name[31]; 
            char kind[31]; 
            char origin[31];  
            int id; 
        }
    struct plant table[50]; 
    void AddPlants(int beginning);
    int GetInfo(char description[], char target[31]);
    int GetID(int n);
    int main(void)
    {
        ...
    }
    ...
    I would like to create table table which will include plant structures. How to do this? How to resolve this poblem?

  2. #2
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Katy, Texas
    Posts
    2,309
    When you declare a struct, you need a semi colon after the closing brace.

    When the compiler sees the second "struct", it tells you it sees "two or more datatypes".
    Mac and Windows cross platform programmer. Ruby lover.

    Quote of the Day
    12/20: Mario F.:I never was, am not, and never will be, one to shut up in the face of something I think is fundamentally wrong.

    Amen brother!

  3. #3
    Registered User
    Join Date
    Nov 2008
    Location
    Chotomów (near Legionowo), POLAND
    Posts
    2
    Thank you

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Writing array, to file
    By zootreeves in forum C Programming
    Replies: 9
    Last Post: 09-08-2007, 05:06 PM
  2. progarm doesnt compile
    By kashifk in forum Linux Programming
    Replies: 2
    Last Post: 10-25-2003, 05:54 PM
  3. extra word printing
    By kashifk in forum C++ Programming
    Replies: 2
    Last Post: 10-25-2003, 04:03 PM
  4. inputting words from a file
    By kashifk in forum C++ Programming
    Replies: 5
    Last Post: 10-24-2003, 07:18 AM
  5. help with operator <
    By kashifk in forum C++ Programming
    Replies: 1
    Last Post: 10-21-2003, 03:49 PM

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