C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 9th, 2012, 05:03 AM
tomynolan tomynolan is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 11 tomynolan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 38 m 12 sec
Reputation 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]

Reply With Quote
  #2  
Old November 9th, 2012, 05:07 AM
G4143 G4143 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 71 G4143 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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?
Code:
temp = getnode();

Reply With Quote
  #3  
Old November 9th, 2012, 05:12 AM
tomynolan tomynolan is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 11 tomynolan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 38 m 12 sec
Reputation Power: 0
Quote:
Originally Posted by G4143
is getnode() spelled correctly here?
Code:
temp = getnode();



Thank you stupid mistake I no but still sat looking at for 45 min going wtf??

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > New to C and Have a problem

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap