473,385 Members | 1,587 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,385 software developers and data experts.

Have a problem in the insertion in the linklist?

Actualy i have a prob in the begaining to add the node in the linklist
i write the following code
i make a display fucnction which display all the value of linklist
i check the value in display function by using printf
by using following statement
Expand|Select|Wrap|Line Numbers
  1. printf("test=%d",current->next->no)
  2.  
i get the expected ans from this statement
after that
i use
Expand|Select|Wrap|Line Numbers
  1. while(current->next!=null)
  2.  
this loop is not working the control is not gone under this statement
if currnet->next->no is shown a value that means
current->next use a pointer which points to the value
thatmeans its not null.
why
Expand|Select|Wrap|Line Numbers
  1. current->next =null 
  2.  
i shown
help me guys
Jul 14 '10 #1
1 1145
weaknessforcats
9,208 Expert Mod 8TB
I would base logic on current rather than current->next.

Suppose your linked list is 1 followed by 2.

When I am on the node with 2, then current->next is null so I don't process the 2. That is, I miss the least element of the list.

After I process the 2, then current becomes
current->next. That is, current becomes null.

Expand|Select|Wrap|Line Numbers
  1. while (current)
  2. {
  3.    /* do stuff */
  4.    current = current->next;
  5. }
Now when you leave the loop, the last node was processed.
Jul 14 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

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. ...
1
by: | last post by:
i have problem about mediaplayer.filename i want my program read songs from a drive(c:\mysongs\?) please help me what i type ?
0
by: graciezzzzz | last post by:
Hi all, I create a Web Service project called 'eSelectService' and another Class Library project called 'MonerisVO', and a Windows Form project called 'maps' as well. The reason why I need...
1
by: vera esaulova | last post by:
I have problem whis Windows Media Services 9 Series. I have videostream, which will consist of two streams(512k/bit and 256k/bit).I need to allocate a stream 256k/bit. In SDK is written: ...
7
by: intrader | last post by:
The regular expression is /(?!((00000)|(11111)))/ in oRe. That is oRE=/(?!((00000)|(11111)))/ The test strings are 92708, 00000, 11111 in checkStr The expression used is checkStr.search(oRE). The...
1
by: noor khanan | last post by:
Hi every boy, I am a beginner. I have a project in access 2003.I have problem to update nonbase table. i have a main form and one subform in it.i want to update my non base table condition in...
0
by: RadhakrishnanR | last post by:
HI ALL, My .NET application devloped in C# used mainly class file (OOAD) and user controls etc and it is desktop application not web based application. Database is SQL server 2000. Now I have...
7
by: sunilsomanna | last post by:
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; ...
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...
1
by: pilafi | last post by:
void CSVImageIO::Read( void * buffer) { char onedataline; char *tmp=0; double d=0; unsigned short data=0; unsigned short * inptr = static_cast< unsigned short * >( buffer ); unsigned...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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,...

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.