473,396 Members | 1,942 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,396 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 1529
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.