Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 132,666 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,154 people online right now. Registration is fast and FREE... Join Now!




help linked list...

 
Reply to this topicStart new topic

help linked list..., i am having trouble in allocating...

moonlight_28
post 5 Sep, 2007 - 12:59 AM
Post #1


New D.I.C Head

*
Joined: 11 Mar, 2007
Posts: 23


My Contributions


how can i allocate a part of memory in linear linked list???

is it like this??

entry = malloc(sizeof (entry) );

or

entry = malloc (sizeof (struct entry) );

error said...

Illegal pointer conversion... Any help will do it...
User is offlineProfile CardPM

Go to the top of the page

PennyBoki
post 5 Sep, 2007 - 01:09 AM
Post #2


system("revolution");

Group Icon
Joined: 11 Dec, 2006
Posts: 2,009



Thanked 5 times

Dream Kudos: 500

Expert In: Java,C++,C

My Contributions


first tell us what is entry is it variable or a structure?

see THIS


This post has been edited by PennyBoki: 5 Sep, 2007 - 01:10 AM
User is offlineProfile CardPM

Go to the top of the page

moonlight_28
post 5 Sep, 2007 - 01:11 AM
Post #3


New D.I.C Head

*
Joined: 11 Mar, 2007
Posts: 23


My Contributions


its like this...

struct link
{
char name[25];
struct link *next;
} *head,*tail,*entry,*temp;

its a variable for structure...
User is offlineProfile CardPM

Go to the top of the page

PennyBoki
post 5 Sep, 2007 - 01:28 AM
Post #4


system("revolution");

Group Icon
Joined: 11 Dec, 2006
Posts: 2,009



Thanked 5 times

Dream Kudos: 500

Expert In: Java,C++,C

My Contributions


In your first post instead
QUOTE
entry = malloc (sizeof (struct entry) );

do
CODE
entry=(struct link *) malloc (sizeof(struct link));


This post has been edited by PennyBoki: 5 Sep, 2007 - 02:34 AM
User is offlineProfile CardPM

Go to the top of the page

Xing
post 5 Sep, 2007 - 05:01 AM
Post #5


D.I.C Addict

Group Icon
Joined: 22 Jul, 2006
Posts: 723



Thanked 2 times

Dream Kudos: 1575
My Contributions


QUOTE(PennyBoki @ 5 Sep, 2007 - 02:58 PM) *

In your first post instead
QUOTE
entry = malloc (sizeof (struct entry) );

do
CODE
entry=(struct link *) malloc (sizeof(struct link));


If it's C, a void pointer can be assigned to any pointer type (except function pointers) safely and without the need for a cast.
User is offlineProfile CardPM

Go to the top of the page

Reply to this topicStart new topic
Time is now: 11/23/08 05:52AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month