#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    11
    Rep Power
    0

    Stuck again help plz.


    Im getting this error of conflicting types even though ive used a prototype??

    error is:
    error: conflicting types for 'addList'

    Code:
    #include <stdio.h>
    #include "stdlib.h"
    typedef struct node {
    	char letter ;
    	struct node *Next;
    }	NODE_TYPE;
    
    //proto's
    NODE_TYPE *getNode();
    void displayList(NODE_TYPE *);
    NODE_TYPE addToList(NODE_TYPE *);
    int emptyList(NODE_TYPE *);
    
    int main(int argc, char **argv)
    {
    	NODE_TYPE *head = NULL ;
    	addToList(head);
    	displayList(head);
    	fflush(stdin);
    	getchar();
    	return 0;
    }
    /*
     * This function addes a new node with info to the head
     * of the list and returns the head
     */
     NODE_TYPE * addToList(NODE_TYPE *head) {
    	 int inchar;
     	printf("Please enter a string of dna!\n (enter 0 to end string)") ;
    	while((inchar=getchar())!= '0') {
    	
    	 	if (emptyList(head)==1) {
    			head = getNode() ;
    			head->Next = NULL ;
    			head->letter = inchar ;
    		 } else {
    	 		NODE_TYPE *temp ;
    	 		temp = getNode();
    	 		temp->Next = head ;
    	 		temp->letter = inchar;
    	 		head = temp;
    		 }
    	}
    	 return head ;
     }
  2. #2
  3. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,413
    Rep Power
    1871
    NODE_TYPE addToList(NODE_TYPE *);
    ...
    NODE_TYPE * addToList(NODE_TYPE *head) {

    You missed a *
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    11
    Rep Power
    0
    Thanks

IMN logo majestic logo threadwatch logo seochat tools logo