Thread: Buggy C code

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    Quote Originally Posted by brewbuck View Post
    '{' character is code. Blegh.
    there is also noparse tag
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  2. #2
    Registered User Alienchicken's Avatar
    Join Date
    Feb 2009
    Posts
    22

    Thumbs up

    Ok thanks guys reviewed my program forgot to declare the fuctions at the top


    But I'm still getting this error

    [Warning] assignment from incompatible pointer type


    in all my functions where i search the next node.

    Code:
         node * curr=top;
                  
            
            while (curr->next!=NULL){
    		printf(" The word ' %s ' occurs %d times\n\n", curr-> word, curr-> count);
    		
    		                                  curr=curr->next;

    the error message is for the
    Code:
    curr=curr->next
    line


    Can someone please explain this error for me. I'd like to know why i get this error message


    btw thanks for the all the help.

  3. #3
    and the hat of copycat stevesmithx's Avatar
    Join Date
    Sep 2007
    Posts
    587
    Quote Originally Posted by Alienchicken View Post
    Ok thanks guys reviewed my program forgot to declare the fuctions at the top


    But I'm still getting this error





    in all my functions where i search the next node.

    Code:
         node * curr=top;
                  
            
            while (curr->next!=NULL){
    		printf(" The word ' %s ' occurs %d times\n\n", curr-> word, curr-> count);
    		
    		                                  curr=curr->next;

    the error message is for the
    Code:
    curr=curr->next
    line


    Can someone please explain this error for me. I'd like to know why i get this error message


    btw thanks for the all the help.
    Well, it would help if you post your recent reviewed code.
    Code:
    typedef struct node{
    char word[50];
    int count;
    struct next *next;
       } node;
    Anyway, my guess is that the error is because curr->next is of type struct next* while curr is of struct node* type.
    For a linked list you need a "self-referential" structure which means probably you need to change the "next" in red above to "node".
    Not everything that can be counted counts, and not everything that counts can be counted
    - Albert Einstein.


    No programming language is perfect. There is not even a single best language; there are only languages well suited or perhaps poorly suited for particular purposes.
    - Herbert Mayer

  4. #4
    Registered User Alienchicken's Avatar
    Join Date
    Feb 2009
    Posts
    22
    Ah yes, that's the problem there you're right. Thanks alot it really helped. My struct declaration was wrong.

  5. #5
    Registered User Alienchicken's Avatar
    Join Date
    Feb 2009
    Posts
    22
    Ok well all that is done but my program still doesn't compile i now get this error message

    [Linker error] undefined reference to `printList'
    [Linker error] undefined reference to `searchList'
    [Linker error] undefined reference to `insertWord'
    ld returned 1 exit status
    [Linker error] undefined reference to `findPrevious'
    Can some one explain what i am doing wrong there


    I am almost done with this prograam once i get this to work the program will most certianly compile successfully.


    btw I've made all the changes that you guys recommended earlier

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Enforcing Machine Code Restrictions?
    By SMurf in forum Tech Board
    Replies: 21
    Last Post: 03-30-2009, 07:34 AM
  2. Obfuscated Code Contest
    By Stack Overflow in forum Contests Board
    Replies: 51
    Last Post: 01-21-2005, 04:17 PM
  3. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM
  4. Replies: 0
    Last Post: 02-21-2002, 06:05 PM
  5. Debugging leads to buggy code and longer hours?
    By no-one in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 01-28-2002, 11:14 AM