Thread: lists error

  1. #1
    Registered User
    Join Date
    Jun 2006

    lists error

    I just started learning linked lists, and i still dont understand them alot. anyway, i wanted to write something like a practice program, where u could insert new elements in struct, but at the very beggining im getting error i've never seen before "two or more data types in 'main'".

    im familiar with c++, but new to c, so i will appreciate any tips about linked lists in c.

    the code isnt nearly finished, so i will change it alot, but i just cannt test it if it works so far, because of the error. here's the code:
    #include <stdlib.h>
    #include <stdio.h>
    struct database {
           int x;
           int y;
           struct database *nextptr;
    int main()
        int k=0;
        struct database *root;
        struct database *ptr;
        root = malloc(sizeof(struct database));
        printf("1) Insert new element\n");
        printf("2) See the list\n");
        printf("3) Exit");
        scanf("%d", k);
            switch (k) {
                   case 1: printf("Inserire valore di x: ");
                           scanf("%d", root->x);
                           printf("Inserire valore di y: ");
                           scanf("%d", root->y);
                   case 2: printf("1) %d, %d", root->x, root->y);
                   case 3: break;
        return 0;
    tnx in advance

  2. #2
    Registered User
    Join Date
    Aug 2005
    Quote Originally Posted by munever
    "two or more data types in 'main'".
    Yeah that's a good one.
    It's caused by a missing semicolon after the declaration of the struct.

  3. #3
    Registered User
    Join Date
    Jun 2006
    tnx for the replie, embaressed

  4. #4
    Join Date
    May 2004
    Don't be. We all miss a semi colon every now and then.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Testing some code, lots of errors...
    By Sparrowhawk in forum C Programming
    Replies: 48
    Last Post: 12-15-2008, 04:09 AM
  3. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  4. Connecting to a mysql server and querying problem
    By Diod in forum C++ Programming
    Replies: 8
    Last Post: 02-13-2006, 10:33 AM
  5. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 01:10 AM