Undefined Structure in Link List

This is a discussion on Undefined Structure in Link List within the C Programming forums, part of the General Programming Boards category; I get these two areas in my add function: Borland C++ 5.5 for Win32 Copyright (c) 1993, 2000 Borland linklistportion.c: ...

  1. #1
    Registered User
    Join Date
    Jan 2003
    Posts
    99

    Undefined Structure in Link List

    I get these two areas in my add function:
    Borland C++ 5.5 for Win32 Copyright (c) 1993, 2000 Borland
    linklistportion.c:
    Error E2450 linklistportion.c 23: Undefined structure 'LIST' in function add
    Error E2109 linklistportion.c 23: Not an allowed type in function add
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    
    struct data{
    	char ip[16];
    	char user[30];
    	struct data *next;
    	};
    typedef struct data LIST;
    typedef LIST *LINK;
    
    LINK add(char *ipaddr, char *username, LINK first);
    char *getuser(char *ipaddr, LINK first);
    void freel(LINK first);
    
    LINK add(char *ipaddr, char *username, LINK first)
    {
    	LINK new=NULL;
    	LINK tmp=NULL;
    	LINK prev=NULL;
    	
    	new = (LINK)malloc(sizeof(struct LIST));
    	if ( !new ){
    		printf("Unable to allocate memory");
    		exit(-1);
    	}

  2. #2
    Registered User
    Join Date
    Feb 2003
    Posts
    76
    You cannot use struct LIST to reference the LIST data type. In your case, either struct data or LIST will work.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Following CTools
    By EstateMatt in forum C Programming
    Replies: 5
    Last Post: 06-26-2008, 10:10 AM
  2. link list error
    By caroundw5h in forum C Programming
    Replies: 2
    Last Post: 04-13-2006, 07:35 PM
  3. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM
  4. Problem with OpenGL tutorial
    By 2Biaz in forum Windows Programming
    Replies: 18
    Last Post: 09-16-2004, 11:02 AM
  5. singly linked list
    By clarinetster in forum C Programming
    Replies: 2
    Last Post: 08-26-2001, 10:21 PM

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