If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Mapping a linked list issue

Hello guys,

I am new to the forum and I kindly ask for help (excuse me for my bad language)

I have a task to write a program Simple Diary (in C++) which has to store notes in a text file but the program have to use data structure. More over the program has to have the ability to search notes by date and print those notes, but the contents of the file must be loaded into the program each time the program starts.

I thought to use list to store the notes into a text file and if the user wants to search, the contents of the file to be stored into another list. Then I wanted to map this list in order to be able to search notes by keyword (date) and print it on the screen if there is a match.

The problem is that I do not know how to map a linked list. Please help me on this. (If there are posts of this kind, please point me to them.)

That entire code maps a number to a linked list of notes using the C++ standard library. Sorting and searching then becomes trivial, which is why I didn't do it above. Note that there are just a few comments in the code -- I leave it to you to look up what that code does above. If you really want to be a good C++ programmer, code as I've written must be immediately understandable, even if you never saw the code before. So you might as well learn what I wrote and how it works.

If you can't use this type of code, the you will get little help coding a linked list yourself unless you coded it and have issues with it (and in that case, the answer would be for you to debug your code).

Re: Mapping a linked list issue

Hello Paul,

First I would like to thank you for your reply - so thank you

It is a little hard for me to fully understand the code above because we did not learned all the things which I see in your code. Still i got the basic idea which you represented. I have developed my own code and I had to use multimap. If it is OK with you I can show you what I did and you could check it?