
November 9th, 2012, 05:07 AM
|
|
Contributing User
|
|
Join Date: Oct 2012
Posts: 71
Time spent in forums: 1 Day 7 h 39 m 39 sec
Reputation Power: 1
|
|
Quote: | 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?
|