Let me clarify this a bit.
The code I put in my original post works when the array is defined at compile-time, according to my instructor. However, the assignment we were given was to dynamically allocate the array. As I understand it pointers HAVE to be used anytime an array is dynamically allocated.
Since the assignment also says that the dynamically allocated array is not to be treated as a 2D array -- we are to not leave empty elements at the end of each "row" -- to print the array would require that another temporary array be allocated, the input line extraced from the original array using memcpy, then the temporary array printed in a loop.
The original array is defined as "char", but we are to use strlen to place the length of each string in the byte immediately preceeding each string, the contents of the string (including the NULL character at the end), then at the very next element the lenght of the next record, the contents of the record, and so on.
Sam Stamport
|