Can you fill a string array without using for loops? For example, if I wanted to store from grades in a class and only wanted to store a name from each line would I be able to? Example (ignore the extra functions, I'm not done with that)
If you want names[0]=Johnson and names[1]=Aniston and you don't want to use a loop just take out the while loop and read each line, assign all the values then work with those.
I believe the OP is wanting to do something like this:
1 2 3 4 5 6 7 8 9 10 11 12
ifstream inFile("myFile.txt");
string myNames[20];
int temp;
for (int i = 0; i < 20; i ++) {
inFile >> myNames[i];
// Discards scores
for (int j = 0; j < 5; j ++)
inFile >> temp;
}
for (int i = 0; i < 20; i ++)
cout << myNames[i] << "\n";
Granted, you're still using a loop (there are better, more efficient ways than what I did), but from what I understand is that you only want the names, you don't care about the scores. Yes, you can still do the above without loops of any type, but the issue comes in the form of not knowing when the end of the file is reached (something I left out in my loop) and manually having to type all of that out, which is really boring.
If this isn't what you were looking for, you might have to explain into more detail.