Storing each line of file with an array of pointers to each line
I have a text file with multiple lines.
dog
cat
goat
I want to save it using an array of pointers that point to each line.
I have been trying things like this
1 2 3 4 5 6
|
string *polyPointers[50];
int i = 0;
while (!polyFile.eof()){
getline(polyFile, line);
line >> polyPointers[i++];
}
|
I want something like.
polyPointers[0] = pointer to dog
polyPointers[1] = pointer to cat
polyPointers[2] = pointer to goat
Why do you want to use pointers at all? Your line 1 might as well be string poly[50];
Topic archived. No new replies allowed.