No, it does not. You certainly can deal with an indefinite number of records and print them all if you process them one at a time. What suggests to me that a container would be useful is the need to sort and perform some unspecified manipulations of the records.Originally Posted by itCbitC
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
No you don't need a linked list if you want to process each record in the input file and print it out at the same time, however if you want to store them for later printing or processing then you do need a linked list as a dynamically allocated array won't do in that case. That's what I was trying to get across.
Last edited by itCbitC; 12-23-2008 at 01:07 PM.
You do not need a linked list, but a linked list certainly would be an option. I would argue that a dynamically allocated array should actually be the "default" to use here, not a linked list. Among other things, sorting would be somewhat easier since qsort() can be used.Originally Posted by itCbitC
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
I just want to point out that I completely understand when 'containers' are useful but that the OPs example was purposefully misleading. All he had to do was include some clue about a sorting step or one of those unspecified operations for me to understand.
Regardless of how wrong I am it appears the OP understands perfectly what went wrong. I'm surprised I did anything worth a thank you, but... confusion happens.
I'll give wollek the benefit of the doubt and say that it was merely accidentally misleadingOriginally Posted by whiteflags
Yes, plus tracking of the size and capacity.Originally Posted by itCbitC
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Sounds like you are a PC based programmer :-)
The little testprogram I posted was just for demonstration.
The screen output is not needed.
The main program is to work with the data. Things like maxima,minima, std deviation , average over a certain time period, a whole bunch of std. mathematical analytics.
This is the part I do not have trouble. I just had encountered the problem that my little test program ran fine while when putting it to the test on a datablock it had failed.
As I said I was chasing the hexdump and had not realized that there was something wrong with my pointer mechanics .
That's when you think you can rest you programming skills for a decade or two and pick up where you have left. :-)
So thanks again for your help, you put me on the right track.