while (fin.good() && nNames < 10)
{
getline(fin, line);
if (line.length() == 0) continue;
std::string tmp_line = line; // this is a temporary variable
transform(tmp_line.begin(), tmp_line.end(), tmp_line.begin(), toUpper()); // apply transform
nameAlreadyExists = false;
for (int i = 0; i < nNames; i++)
{
std::string tmp_name = name[i]; // this is the temporary variable for name
transform(tmp_name.begin(), tmp_name.end(), tmp_name.begin(), toUpper()); // apply transform
if (tmp_name == tmp_line) nameAlreadyExists = true; // compare with the temporary variable
}
if (!nameAlreadyExists && nNames < MAX_NAMES) {
name[nNames++] = line; // but store the original variable
}
}
do the same in the second loop
[EDIT]Note that you need a temporary variable for name[i] as well
You may want a function that returns the transformed string