The OP doesn't know how many records are in that file, besides (s)he needs to print them out at the end. Doesn't that say linked list loud 'n clear.
Printable View
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.Quote:
Originally Posted by itCbitC
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.
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.Quote:
Originally Posted by itCbitC
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 misleading :DQuote:
Originally Posted by whiteflags
Yes, plus tracking of the size and capacity.Quote:
Originally Posted by itCbitC
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.