473,395 Members | 1,568 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

problem with linklist

template<class T>
void TimerDLList<T>::addFirst(TimerItem<T>* const itemPtr)
{
// suppose itemPtr is not pointing to NULL

itemPtr->prev = (TimerItem<T>*) NULL;

head = (TimerItem<T>*)NULL;

if (tail == (TimerItem<T>*)NULL ) // nothing in the link list
{
tail = itemPtr;
itemPtr->next = (TimerItem<T>*) NULL;
}
else
{
itemPtr->next = head;
head->prev = itemPtr;
}

head = itemPtr;
}

there seems to be some problem in head->prev = itemPtr.
There seems to be some corrution at this point.
PLEASE HELP.......
seems like head->prev is accessing a wrong address.

Jul 5 '07 #1
3 1528
On Jul 5, 8:05 am, sunilsoma...@gmail.com wrote:
template<class T>
void TimerDLList<T>::addFirst(TimerItem<T>* const itemPtr)
Looks like C++ to me. You may want comp.lang.c++ or a platform-
specific newsgroup, but not comp.lang.c.

-thomas

Jul 5 '07 #2
su**********@gmail.com wrote:
template<class T>
void TimerDLList<T>::addFirst(TimerItem<T>* const itemPtr)
This looks lik C++, but this comp.lang.c, not comp.lang.c++.
{
// suppose itemPtr is not pointing to NULL
itemPtr->prev = (TimerItem<T>*) NULL;
head = (TimerItem<T>*)NULL;
if (tail == (TimerItem<T>*)NULL ) // nothing in the link list
{
tail = itemPtr;
itemPtr->next = (TimerItem<T>*) NULL;
}
else
{
itemPtr->next = head;
head->prev = itemPtr;
}
head = itemPtr;
}
there seems to be some problem in head->prev = itemPtr.
When you first set 'head' to NULL then you shouldn't be too
astonished when you can't dereference it later on...

Regards, Jens
--
\ Jens Thoms Toerring ___ jt@toerring.de
\__________________________ http://toerring.de
Jul 5 '07 #3
su**********@gmail.com wrote:
template<class T>
void TimerDLList<T>::addFirst(TimerItem<T>* const itemPtr)
There are languages in which the above makes sense (C++ springs to
mind), but C is not one of them. If your question is about the
programming language C++, you might find an answer if you posted to a
C++ newsgroup. <news:comp.lang.c++is one of those. If it is some
other language, you will need to look for the appropriate newsgroup.

Jul 5 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: jova | last post by:
I'm stuck I have to convert an array to a linklist the array is initialized as public Organization{ Crew members = new Member etc....
1
by: CoreyMas | last post by:
Hello all, Here is my situation I am trying to create a dataview with the following rowfilter PMA_DatakeyId IN...
13
by: ashu | last post by:
hi to all, Please read the following ques. first. assume that a bank maintains 2 kinds of accounts for customers one called as savings accounts & other as current account. the savings account...
7
by: vjay | last post by:
I want to just create a linklist.The program below goes into an endless loop.The srange behaviour is that i can exit from the program if i create only two nodes.After two goes into infinite loop. ...
6
by: jwvai316 | last post by:
I don't really know how to say it so I just say it a nested linklist. How do you make LinkLists inside LinkList? Can anyone help me for this? I think an example program will help me a lot. ...
0
by: prashant0903 | last post by:
how i 'll made the linklist program in java both included insertion & deletion in program
2
by: mithaelin | last post by:
ok, I can't get out of this riddle and Google seems can't help me. The problem is that this code doesn't work in iexplorer while it's perfect in other browser (didn't check in safari): <html>...
1
by: smoothkriminal1 | last post by:
Write a Code that will pick timetable of 40 students from file using linklist n than find a slot where all the students dont have any class. file can be of any format Student can maximum take 6...
2
Parul Bagadia
by: Parul Bagadia | last post by:
I have written a code for deleting certain value from linklist; it's not working; where as i have written one for deleting a no., after given no. which works fine! I even debugged it; but invain;...
2
by: dynamo | last post by:
this is a basic linklist,there seems to be a runtime error when i run the program(the main function) i suspect it has something to do with my del function but i see nothing wrong can you help.Thanx...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.