This is a discussion on problem with reading struct from file generated by hexdump within the C Programming forums, part of the General Programming Boards category; Originally Posted by whiteflags I'm not convinced he needs a collection of records at all. The OP doesn't know how ...
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
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
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
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.