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

    Join Date
    Nov 2012
    Posts
    11
    Rep Power
    0

    Question New to C and Have a problem


    So I have to impalement a link list to store a string of DNA but i keep getting the following error but cant fix it help plz!

    Code:
    #include <stdio.h>
    #include "stdlib.h"
    typedef struct node {
    	char letter ;
    	struct node *Next;
    }	NODE_TYPE;
    
    //prototypes
    NODE_TYPE * getNode(void) ;
    
    int main(int argc, char **argv)
    {
    	printf("  ") ;
    	return 0;
    }
    /*
     * Allocates memory for a new node and return a pointer 
     *to the Memory
     */
    NODE_TYPE *getNode(void) {
    			NODE_TYPE *pt ;
    
        pt = (NODE_TYPE *) malloc(sizeof(NODE_TYPE) ) ;
        if (pt == (NODE_TYPE *) NULL )
        {
    	printf("Failed to allocate memory\n") ;
    	exit(1) ;
        } 
        return pt ;
    }//getnode
    
    /* Boolean Function to determine if list is empty */
    int emptyList(NODE_TYPE *p2n)
    {
    	return (p2n==NULL);
    }
    
    /*
     * This function addes a new node with info to the head
     * of the list and returns the head
     */
     NODE_TYPE *addTolist(NODE_TYPE *head, char letter) {
    	 if (emptyList(head)==1) {
    		head = getNode() ;
    		head->Next = NULL ;
    	 } else {
    	 	NODE_TYPE *temp ;
    	 	temp = getnode(); //<-error comes up here
    	 	temp->Next = head ;
    	 	head = temp;
    	 }
    	 return head ;
     }
    the error is
    DNA.c:48:9: warning: assignment makes pointer from integer without a cast [enabled by default]
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    71
    Rep Power
    3
    Originally Posted by tomynolan
    So I have to impalement a link list to store a string of DNA but i keep getting the following error but cant fix it help plz!

    Code:
    #include <stdio.h>
    #include "stdlib.h"
    typedef struct node {
    	char letter ;
    	struct node *Next;
    }	NODE_TYPE;
    
    //prototypes
    NODE_TYPE * getNode(void) ;
    
    int main(int argc, char **argv)
    {
    	printf("  ") ;
    	return 0;
    }
    /*
     * Allocates memory for a new node and return a pointer 
     *to the Memory
     */
    NODE_TYPE *getNode(void) {
    			NODE_TYPE *pt ;
    
        pt = (NODE_TYPE *) malloc(sizeof(NODE_TYPE) ) ;
        if (pt == (NODE_TYPE *) NULL )
        {
    	printf("Failed to allocate memory\n") ;
    	exit(1) ;
        } 
        return pt ;
    }//getnode
    
    /* Boolean Function to determine if list is empty */
    int emptyList(NODE_TYPE *p2n)
    {
    	return (p2n==NULL);
    }
    
    /*
     * This function addes a new node with info to the head
     * of the list and returns the head
     */
     NODE_TYPE *addTolist(NODE_TYPE *head, char letter) {
    	 if (emptyList(head)==1) {
    		head = getNode() ;
    		head->Next = NULL ;
    	 } else {
    	 	NODE_TYPE *temp ;
    	 	temp = getnode(); //<-error comes up here
    	 	temp->Next = head ;
    	 	head = temp;
    	 }
    	 return head ;
     }
    the error is
    DNA.c:48:9: warning: assignment makes pointer from integer without a cast [enabled by default]
    is getnode() spelled correctly here?
    Code:
    temp = getnode();
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    11
    Rep Power
    0
    Originally Posted by G4143
    is getnode() spelled correctly here?
    Code:
    temp = getnode();
    :eek:
    Thank you stupid mistake I no but still sat looking at for 45 min going wtf??

IMN logo majestic logo threadwatch logo seochat tools logo