Linked List error [SOLVED]

I have written linked lists many times, but I'm stumped by this error.
header
#include <stdio.h>
typedef struct
char *str;
struct strstack *next;
} strstack;
void connect(struct strstack *a, struct strstack *b);
source
#include <stdio.h>
#include "strstack.h"
void connect(struct strstack *a, struct strstack *b)
a->next = b;
errors
gcc -g -O2 --std=c99 -c strstack.c
strstack.c: In function 'connect':
strstack.c:7: error: dereferencing pointer to incomplete type
make: *** [strstack] Error 1
Does anybody have any idea what causes this?
Last edited by Lexion (2009-09-12 23:48:49)

Yes.
Your typedef is silly.
Replace with
typedef struct stack_s
char *str;
struct stack_s *next;
} stack_t;
or similar.
You have to name the struct, and use the struct name when declaring the next pointer. You can typedef it too, if you want to, but that name can't be used in the struct declaration.

Similar Messages

  • Linked list- error problem.... HELP!!!

    Just got to the point that i'm better at drinking java than programing java....
    how ever... I have done person register with Linked list. There are like 4 options:
    1. New post
    2. search
    3. search and change
    4. remove post
    U can enter your name, adress and personal code number while making a new post, but when I've removed it ( l.list.remove(p);)and then search for it I get the error message "Exception in thread "main"....bla bla..". Why? and how do I get around this prob? PLEASE HELP ME!! gotta hand this in tonight!
    Thank U!!
    //Phil

    Phil,
    LinkedList itself works as advertised (1.3.1). For example:
    LL = LinkedList()
    LL.add("apple")
    LL.add("battle")
    LL.add("cattle")
    // printing LL yields all 3
    LL.remove("battle")
    // printing LL yields apple, cattle
    You may need to post for responders to get a better idea. If posting code please enclose in  blocks so it's formatted properly.
    --A                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Baffling linked list error in C program

    I've been working at porting some programs over to a Mac that were built using MS C 6.0.  One of the programs uses a linked list to hold some data.  Just couldn't get it to work.  So I decided to run a really simple test.  Create a short linked list and then print out the list.
    The code is below and the output is below that.  It looks like all the nodes get created properly and pointers assigned correctly but when I print out the list it crashes after the second node everytime.  It appears that in node 2 the link to the next node has been corrupted but I can't see anywhere that happens.  Is this not the way xcode does linked lists?
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <math.h>
    struct linklist {
        int node_number;
        char node_name[10];
        struct linklist * next;
    struct linklist * makenode();
    int main(int argc, const char * argv[])
        struct linklist * list_head;
        struct linklist * list_item;
        int i;
        // insert code here...
        printf("Hello, World!\n");
        list_head = makenode();
        list_head->node_number = 1;
        strcpy(list_head->node_name, "node 1");
        list_head->next = NULL;
        list_item = list_head;
        printf("head-> %0lx, item-> %0lx \n", (unsigned long) list_head, (unsigned long) list_item);
        for (i = 1; i < 10; i++)
            list_item->next = makenode();
            printf("New Node %d at %lu\n", i+1, (unsigned long) list_item->next);
            list_item = list_item->next;
            list_item->node_number = i+1;
            sprintf(list_item->node_name, "node %d", i+1);
            list_item->next = NULL;
            printf("list_item points at %lu\n", (unsigned long) list_item);
        list_item = list_head;
        for (i = 0; i < 10; i++)
            printf("list_item -> %lu>\n", (unsigned long) list_item);
            printf("%d - %s>\n", list_item->node_number, list_item->node_name);
            list_item = list_item->next;
        return 0;
    struct linklist * makenode()
        return (struct linklist *) (malloc( sizeof(struct linklist())));
    Output>>>>>
    Hello, World!
    head-> 7fdf604000e0, item-> 7fdf604000e0
    New Node 2 at 140597369256496
    list_item points at 140597369256496
    New Node 3 at 140597369256512
    list_item points at 140597369256512
    New Node 4 at 140597369256528
    list_item points at 140597369256528
    New Node 5 at 140597369256544
    list_item points at 140597369256544
    New Node 6 at 140597369256560
    list_item points at 140597369256560
    New Node 7 at 140597369256576
    list_item points at 140597369256576
    New Node 8 at 140597369256592
    list_item points at 140597369256592
    New Node 9 at 140597369256608
    list_item points at 140597369256608
    New Node 10 at 140597369256624
    list_item points at 140597369256624
    list_item -> 140597369241824>
    1 - node 1>
    list_item -> 140597369256496>
    2 - node 2>
    list_item -> 7306087013738872835>

    Change
    return (struct linklist *) (malloc( sizeof(struct linklist())));
    to
        return (struct linklist *) (malloc( sizeof(struct linklist)));
    Hello, World!
    head-> 100103b10, item-> 100103b10
    New Node 2 at 4296031024
    list_item points at 4296031024
    New Node 3 at 4296031056
    list_item points at 4296031056
    New Node 4 at 4296031088
    list_item points at 4296031088
    New Node 5 at 4296031120
    list_item points at 4296031120
    New Node 6 at 4296031152
    list_item points at 4296031152
    New Node 7 at 4296031184
    list_item points at 4296031184
    New Node 8 at 4296031216
    list_item points at 4296031216
    New Node 9 at 4296031248
    list_item points at 4296031248
    New Node 10 at 4296031280
    list_item points at 4296031280
    list_item -> 4296030992>
    1 - node 1>
    list_item -> 4296031024>
    2 - node 2>
    list_item -> 4296031056>
    3 - node 3>
    list_item -> 4296031088>
    4 - node 4>
    list_item -> 4296031120>
    5 - node 5>
    list_item -> 4296031152>
    6 - node 6>
    list_item -> 4296031184>
    7 - node 7>
    list_item -> 4296031216>
    8 - node 8>
    list_item -> 4296031248>
    9 - node 9>
    list_item -> 4296031280>
    10 - node 10>
    Program ended with exit code: 0

  • Linked list error

    Can anyone tell what's wrong with the following code?
    It says arguments(int) is not supported, but I don't know what it means.
    Thank you.
    import java.util.*;
    public class tester {
          * @param args
         public static void main(String[] args) {
              // TODO Auto-generated method stub
              LinkedList Customers = new LinkedList();
              for (int k=1;k<=5;k++)
                   Customers.addLast(k);
              System.out.println(Customers);
              System.out.println(Customers.indexOf(3));
              Customers.removeFirst();
              System.out.println(Customers);
              System.out.println(Customers.indexOf(3));
              System.out.println(Math.random()*10);
    }

    What version of Java are you using? Collections can only hold objects, not primitives. In Java 5 (or was it 4) they introduced autoboxing which automatically "boxes" the primitive value into its wrapper class and then stores that in the Collection.

  • Errors executing bulk query when updating a Sharepoint Linked List from Access

    Hi all,
    I have a Sharepoint list that is a Linked List with MS Access. It has just under 5,000 items (4,864), thus meaning it avoids the reduction in functionality lists of greater than 5,000 items have.
    Among the list are five calculated columns. These take the information from another column (different employee numbers), and by using a formula produce a clickable link to my company's Directory page, where that particular employee's info is displayed. I'm
    not sure if these five columns are relevant to my query, but I'm mentioning them in case.
    My problem is this: Frequently when I run any query on the list that updates the list, I get this error: "There were errors executing the bulk query or sending the data to the server. Reconnect the tables to resolve the
    conflicts or discard the pending changes".
    When I review the errors, it says they conflict with errors a previous user made (with that previous user being me). It frequently highlights several columns, despite the info in them being identical, and the calculated columns (with the original showing
    the value they contained and the new showing #VALUE! (as Access can't display the formulas).
    However, if I click Retry All Changes, all the update stick and everything seems fine. Why is this happening? It's proving very annoying and is really stopping the automation of my large number of queries. A list of 5000 items isn't particular big (and they've
    got roughly 100 columns, although I didn't think that was too large either, given Excel's 200+ column limit).
    Is this due to poor query design and SQL? Is this due to connectivity issues (which I doubt, as my line seems perfect)? Is this due to Access tripping over itself and not executing the update on each row in the table, but rather executing them concurrently
    and locking itself up? I'm at wit's end about it and really need to get this sorted.
    Thanks in advance for any suggestions.

    Hi amartin903,
    According to your description, my understanding is that you got an error when you used a linked list from Access.
    The table that you are updating is a linked table that does not have a primary key or a unique index. Or, the query or the form is based on a linked table that does not have a primary key or a unique index. Please add the primary key or a unique index.
    Here is a similar post, please take a look at:
    http://social.technet.microsoft.com/Forums/en-US/545601e9-a703-4a02-8ed9-199f1ce9dac8/updating-sharepoint-list-from-access?forum=sharepointdevelopmentlegacy
    I hope this helps.
    Thanks,
    Wendy
    Wendy Li
    TechNet Community Support

  • [svn:bz-trunk] 18926: bug fix BLZ-570 Double linked list with lot of objects result in BlazeDS Error deserializing error  : StackOverflowError

    Revision: 18926
    Revision: 18926
    Author:   [email protected]
    Date:     2010-12-01 14:07:19 -0800 (Wed, 01 Dec 2010)
    Log Message:
    bug fix BLZ-570 Double linked list with lot of objects result in BlazeDS Error deserializing error : StackOverflowError
    We put hard limit to the max object nest level to prevent StackOverFlowError. the default max object nest level is 1024 and it can be configured in the endpoint/serialziation section in service-config.xml.
    This needs documentation.
    Checkintests pass
    Ticket Links:
        http://bugs.adobe.com/jira/browse/BLZ-570
    Modified Paths:
        blazeds/trunk/modules/common/src/flex/messaging/errors.properties
        blazeds/trunk/modules/core/src/flex/messaging/endpoints/AbstractEndpoint.java
        blazeds/trunk/modules/core/src/flex/messaging/io/SerializationContext.java
        blazeds/trunk/modules/core/src/flex/messaging/io/amf/Amf0Input.java
        blazeds/trunk/modules/core/src/flex/messaging/io/amf/Amf3Input.java
        blazeds/trunk/modules/core/src/flex/messaging/io/amf/AmfIO.java

  • [svn:bz-4.0.0_fixes] 20451: backporting bug fix BLZ-570/ BLZ-620 Double linked list with lot of objects result in BlazeDS Error deserializing error  : StackOverflowError  We put hard limit to the max object nest level to prevent StackOverFlowError .

    Revision: 20451
    Revision: 20451
    Author:   [email protected]
    Date:     2011-02-24 08:33:31 -0800 (Thu, 24 Feb 2011)
    Log Message:
    backporting bug fix BLZ-570/BLZ-620 Double linked list with lot of objects result in BlazeDS Error deserializing error : StackOverflowError  We put hard limit to the max object nest level to prevent StackOverFlowError. the default max object nest level is 1024 and it can be configured in the endpoint/serialziation section in service-config.xml. This needs documentation.  Checkintests pass
    Ticket Links:
        http://bugs.adobe.com/jira/browse/BLZ-570
        http://bugs.adobe.com/jira/browse/BLZ-620
    Modified Paths:
        blazeds/branches/4.0.0_fixes/modules/common/src/flex/messaging/errors.properties
        blazeds/branches/4.0.0_fixes/modules/core/src/flex/messaging/endpoints/AbstractEndpoint.j ava
        blazeds/branches/4.0.0_fixes/modules/core/src/flex/messaging/io/SerializationContext.java
        blazeds/branches/4.0.0_fixes/modules/core/src/flex/messaging/io/amf/Amf0Input.java
        blazeds/branches/4.0.0_fixes/modules/core/src/flex/messaging/io/amf/Amf3Input.java
        blazeds/branches/4.0.0_fixes/modules/core/src/flex/messaging/io/amf/AmfIO.java

    Dear Pallavi,
    Very useful post!
    I am looking for similar accelerators for
    Software Inventory Accelerator
    Hardware Inventory Accelerator
    Interfaces Inventory
    Customization Assessment Accelerator
    Sizing Tool
    Which helps us to come up with the relevant Bill of Matetials for every area mentioned above, and the ones which I dont know...
    Request help on such accelerators... Any clues?
    Any reply, help is highly appreciated.
    Regards
    Manish Madhav

  • [svn:bz-3.x] 20443: back porting bug fix BLZ-570/ BLZ-620 Double linked list with lot of objects result in BlazeDS Error deserializing error  : StackOverflowError  We put hard limit to the max object nest level to prevent StackOverFlowError .

    Revision: 20443
    Revision: 20443
    Author:   [email protected]
    Date:     2011-02-23 21:19:22 -0800 (Wed, 23 Feb 2011)
    Log Message:
    back porting bug fix BLZ-570/BLZ-620 Double linked list with lot of objects result in BlazeDS Error deserializing error : StackOverflowError  We put hard limit to the max object nest level to prevent StackOverFlowError. the default max object nest level is 1024 and it can be configured in the endpoint/serialziation section in service-config.xml. This needs documentation.  Checkintests pass
    Ticket Links:
        http://bugs.adobe.com/jira/browse/BLZ-570
        http://bugs.adobe.com/jira/browse/BLZ-620
    Modified Paths:
        blazeds/branches/3.x/modules/common/src/java/flex/messaging/errors.properties
        blazeds/branches/3.x/modules/core/src/java/flex/messaging/endpoints/AbstractEndpoint.java
        blazeds/branches/3.x/modules/core/src/java/flex/messaging/io/SerializationContext.java
        blazeds/branches/3.x/modules/core/src/java/flex/messaging/io/amf/Amf0Input.java
        blazeds/branches/3.x/modules/core/src/java/flex/messaging/io/amf/Amf3Input.java
        blazeds/branches/3.x/modules/core/src/java/flex/messaging/io/amf/AmfIO.java

  • What can be the error in this simple Linked List Implementation

    i have a linked list code that wont compile successfully. The code is
    //Lets try the Linked List 
    import java.util.*;
    class LinkedListDemo {
    public static void main ( String args[]){
         LinkedList l1=new LinkedList();
         l1.add( "A");
         l1.add(2);
         l1.add(3);
         l1.add(4);
         l1.add(5);
         l1.addFirst(6);
         l1.add(7);
         l1.add(8);
         l1.add(9);
         //Lets check what does the Linked List hold at this time
         System.out.println("Prsently the linked lis is having:  "+l1);
    }Problem is with the add method . Compiler error is that it doesnt recognize the symbol ie add method.

    i m sorry , java version is 1.4In that case, read up on the link jverd posted on AutoBoxing. You can only add Objects to a List. An int is a primitive, not an Object. You can try something like this:
    l1.add(new Integer(2));

  • Runtime Error displaying Linked List

    Hi, I've got a main class with a linked list which I am trying to display but I seem to be getting a "Class Cast Exception" eventhough I type cast the list as a String. Can anyone help please. The code is below:
    import java.util.*;
    public class Library
         public static void main (String[] args)
              LinkedList myList = new LinkedList();
              LibraryItems libraryItems = new LibraryItems("Java how to Program", 10);
              myList.add(libraryItems);
              ListIterator myListIterator = myList.listIterator();
              while (myListIterator.hasNext())
                   String itemlist = (String) myListIterator.next();//this is where the runtime error occurs
                   libraryItems = (LibraryItems) myList.getFirst();
                   System.out.println(itemlist + " " + libraryItems.getItemName() + " "+
                                            libraryItems.getItemNumber());
    }and here is the supporting class:
    import java.util.LinkedList;
    public class LibraryItems
         private String itemName;
         private int   itemNumber;
         public LibraryItems(String itemName, int itemNumber)
              this.itemName = itemName;
              this.itemNumber = itemNumber;
         public String getItemName()
              return itemName;
         public int getItemNumber()
              return itemNumber;
    }Any help would really be appreciated.

    You add LibraryItems to the LinkedList, but when you get them out, you are casting to String.
    probably
    LibraryItems itemlist = (LibraryItems) myListIterator.next();
    System.out.println(itemlist.getItemName()...

  • Strange error message - linked lists (again)

    I have to keep at this linked list thing if I'm ever going to really understand it!!
    I have created a method to create a linked list via user input. I'm receiving only one strange ERROR, which states:
    "This method must return a result of of type ListADT.Node."
    And I have just started building my class ListADT...
    class ListADT{
    public Node createList(int aNumber){     // THIS IS WHERE THE ERROR POINTS
          * integer variable aNumber is the length of the list user wishes to create.
         Scanner console = new Scanner(System.in);
         int number;                    // declare variable number as an integer.
         Node newNode = new Node();          // declare and initialize newNode.
         Node first = new Node();          // declare and initialize first.
         Node last = new Node();               // delcare and initizlize last.
         try
              for(int i = 0; i <= aNumber; i++){               // for loop to enter numbers to build list.
              System.out.println("Please enter an integer: ");     // prompt user.
              number = console.nextInt();                    // assign user input to variable number.
              newNode.info = number;          // assign number to newNode;
              if(first == null){               // checks to see if Node first is a null value.
                   first = newNode;          // if true, then this node is the first and last node in the list.
                   last = newNode;
              else{                              // if first is not null, then newNode is placed at the end of the list.
                   last.link = newNode;
                   last = newNode;
              return first;
         catch (InputMismatchException imeRef)     //Catches non-integer values
              System.out.println("You entered a non-Integer! " + imeRef.toString());     //Prints error message

    Now why can't the error messages help
    out a little more? I would have never guessed that
    there was a problem with the catch block not
    returning anything!!The message was pretty informative -- it told you what was wrong. If the compiler could be so smart as to be able to tell you exactly what to fix, then the compiler would be able to write code all by itself -- and then you'd be out of a job.

  • Circular Linked List

    Hello,
    I am working with circular linked Lists. Now the thing is that my assignment was to make this. I had to write a set of methods. Now the thing is that I had to write a method that removes the last value. I made it but it doesnt wark and also i am confused
    public Object removeFirst()
             if(size()==0)
                return "empty list";
             Object temp = last.getNext().getValue();
             last.setNext(last.getNext().getNext());
             size--;
             return temp;
          //doesnt Work
           public Object removeLast()
              public Object removeLast()
             if (size()==0)
                return "empty list";
             Object temp= null;
             temp = last.getNext().getValue();
             last = last.getNext();
             size--;
             return temp;  
          }

    Well what is wrong with the code?
    Does it compile?
    Does it throw an error at runtime?
    Does it give you an unexpected answer?
    For solving problems like this with next/prev "pointers" I find diagramming boxes with arrows to help understand is an absolute requirement. Try figuring it out on paper.
    If you are removing the last item in the list, that means that the item directly before this one, has to the next one in the list
    Assuming you have a structure like this:
    ...-->  (n-1)  -->  (n)  --> (1) --> (2) -->...(n-1)Then removing item (n) you have to make (n-1) point at item (1) as item (n-1) becomes the new "last"
    So you have to have the item before the "last" element to keep the next/prev pointers correct.

  • Trouble importing third party classes & using linked list in j2me

    Hi!
    I need to use the linked list data structure in a j2me application im developing. Al long as I know, it is not included in standard libraries.
    I found the "workaround", the substitution in Jade Laepaddon. This is actually a set of classes in a directory.
    I know this is extremely dumb, but I have no luck impotring these classes in my project.
    Im using the WTK2.0 to compile and execute the application, but I don't have an Idea how to add a directory in the CLASSPATH.
    So, the actual question should be: how to include a directory of files, so that it can be imported with:
    import dirName.*;
    Thanks!

    Tha import problem is solved, but I'm still not able to use the LinkedList class. In the jade/util/leap there is a LinkedList.java file, but I get an error :
    /home/mile/WTK2.0/apps/myGame/tmplib/jade.jar(jade/util/leap/LinkedList.java):48: class LinkedList is public, should be declared in a file named LinkedList.java
    (source unavailable)
    /home/mile/WTK2.0/apps/myGame/tmplib/jade.jar(jade/util/leap/LinkedList.java):48: cannot resolve symbol
    symbol : class List
    location: class jade.util.leap.LinkedList
    (source unavailable)
    /home/mile/WTK2.0/apps/myGame/tmplib/jade.jar(jade/util/leap/LinkedList.java):48: cannot resolve symbol
    symbol : class Serializable
    location: class jade.util.leap.LinkedList
    (source unavailable)
    /home/mile/WTK2.0/apps/myGame/tmplib/jade.jar(jade/util/leap/Iterator.java):41: class Iterator is public, should be declared in a file named Iterator.java
    (source unavailable)
    when initialising an LinkedList type object.

  • White list error message

    Hi Experts!
    We have an issue when displaying originals(in DIRs) in PLM WUI, Portal.
    The issue can be summarized like this:
    JPG-Images or PDF files are stored on a shared folder. (Not in SAP System)
    We then create an original in a DIR(document info record). We do NOT check in the original but only use file as a link.
    (In our solution we will not check in the originals but the versioning will be controlled in the linked folder).
    Example:
    We create an original with the following link
    sharedfolder\images\image01.jpg
    Anyone can afterwards log on the system and click display original and the jpf or pdf is shown.
    This procedure works perfectly fine when we are in SAPGUI.
    But in the Portal the system acts different from case to case.
    Case 1
    When a colleague of mine has added an original in SAPGUI and I
    then press display in Portal I get a security list error message, Wrong downloading server
    (We have defined the white list, TCode wdr_acf_wlist, and downloaded it.
    In this case we have tried
    sharedfolder\images\ as downloading server for example)
    Case 2
    When I have added an original in SAPGUI and then press display in the Portal the image is shown
    ->Why do I NOT get the error message in this case?
    Any ideas why the system works this way and how I can solve it?
    Thanks in advance!
    Mikael

    Hi Mikael,
    I was led to this thread via search on SDN for "white list". We need to set up an external facing portal and need to set up reverse proxy plus white list. We have an OSS message running with prio very high but don't seem to get a helpful answer. Can you give info on how to configure the revese proxy (we aim at citrix gateway as reverse proxy) with white list? or can you describe your architecture with focus on white list? very kind regards, Matthias Kasig

  • Listing errors prior to running a sequence

    Is there a way to display\list errors in TestStand prior to running a sequence.
    For example, a section of code changes. It now has more parameters being sent to a function inside a dll.
    Up until now the only way to find it to run the code, wait for it to error out, then trace where the offending parameter is.
    any suggestions?
    thanks
    Solved!
    Go to Solution.

    In TestStand 4.5 and later you can analyze your sequence file and catch this.  Unfortunately before that there is no way to do so.
    Check out the what's new: http://www.ni.com/teststand/whatsnew/
    Here's a link to the actual whitepaper: http://zone.ni.com/devzone/cda/tut/p/id/12254
    jigg
    CTA, CLA
    teststandhelp.com
    ~Will work for kudos and/or BBQ~

Maybe you are looking for