I am relatively new to C++, and I am attempting to read sequenceofchars from a text file into a char array that is dynamically allocated. My code is as follows:
while (file.get(c))
{
if (c =='\n')
continue;
char *temp = new char[i++];
arrayA = new char[i++];
arrayA[i] = c;
delete [] arrayA;
arrayA = temp;
}
And the text file format is as follows:
>NameOfChars
sequenceofchars
This is obviously horribly broken, but I've struggled to figure out the exact methodology one would use to go through this. I know about the Vector class, but I am unsure about how to go about using that if that is the preferred method for reallocating arrays on the heap. Any help would be greatly appreciated. Thank you.