Thread: Table of structures

  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
    Chappell Hill, Texas
    Posts
    2,332
    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".
    Mainframe assembler programmer by trade. C coder when I can.

  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