lists error

This is a discussion on lists error within the C Programming forums, part of the General Programming Boards category; I just started learning linked lists, and i still dont understand them alot. anyway, i wanted to write something like ...

  1. #1
    Registered User
    Join Date
    Jun 2006
    Posts
    4

    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:
    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));
        root->x=0;
        root->y=0;
        root->nextptr=0;
        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);
                           break;
                   case 2: printf("1) %d, %d", root->x, root->y);
                           break;
                   case 3: break;
                   }
    
        system("PAUSE");
        return 0;
    }
    tnx in advance

  2. #2
    ZuK
    ZuK is offline
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    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.
    Kurt

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

  4. #4
    ---
    Join Date
    May 2004
    Posts
    1,379
    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, 09: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

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