count how many time the value appear in the link list -- HELP

This is a discussion on count how many time the value appear in the link list -- HELP within the C++ Programming forums, part of the General Programming Boards category; i think you are right..
so what you mean is that the display function is miss coded right?
i dont ...

id rather communicate here because: its permanent (or almost!), its public (so others can help and learn), and you can post your full code here with code tags for nice formatting.

i dont think anythings wrong with your display function. please reread my previous response to see if it makes any other sense to you... i think you just need ONE node PER ip address. if you have a duplicate ip address, then increase that node's count variable.

i dont see why you want to have duplicated nodes. (note: i said duplicated NODES not IP addresses)

im kind of confused about the count. does this list contain duplicate IP addresses? if so, why is there a need to have duplicates?

can you explain what the class in general is to do and this updateCount function in particular, then i can try and help.

edit: i read your comments in the code so please dont just repeat those, if you can

this list will contain duplicate address. it cannot be change cause is a part of work....

ok here is the explanation of overall work ...

<this program reads these IP addresses from a file and stores them in a linked list where each node will store the addresses and the number of times that address appears in the data file. list will be ordered in ascending order by IP address...As each address is read the program showuld check if it is already in the list. if it is then its count should be incremented by 1. if it isnt alreadyy int the list . should be inserted into the list so as to maintain the ordering of the list.

this IS how it would look if you had duplicate NODES. you dont want duplicate nodes, you want duplicate IP ADDRESSES. a duplicate ip address is simply a node whose ip address has appeared 1+ times (which is stored in it's count variable).
this is how the output would appear if you dont have duplicate nodes (note you still have duplicate ip addresses):

You state in the preconditions to that function that a node with that address has to exist, so why do you create a new one ?.
If you really want to create a new node then you would have to remove the old one from the list and replace it with the new one.
Kurt

I'm not talking about the overall logic. I'm talking about the precondition to the function updateCount().
If exitance of the address is a precondition then updateCount() must not be called if the address doesn't exist. So according to the stated predcondition updateCount() has to find the node containing that address and simply increment its count member. No need to create a new node.
BTW: the way your function works now you would create a memory leak because you don't free the old node and you don't link the new node into the list.
Kurt