How to convert subscripts to pointers
Hello,
How do I convert the following to use pointers instead of subscripts?
short i;
char words [2000];
for (r=0; r < NumRows; r++)
cout << words[r];
In the assignment we were given we were told to dynamically allocate an array, read an input file of strings, and store each string in the array preceeded by a one-byte field containing the length of that string. Further the assignment says to not leave unused elements after each string.
The only way I can figure out how to do this is to create another temporary array and do a memcpy after properly positioning the pointer and then do the cout from the temporary array.
Sam Stamport
__________________
Sam Stamport
|