In need of help skipping any exact (case-independent) duplicates in sorting arrays

SOLVED
Last edited on
The only part I'm stuck on is having my program skip over any case independent duplicates
Well then, apply transform() to line (after line 43) only. So you don't need further transform() and you get rid of the duplicate
SOLVED
Last edited on
temporary variables are nothing special:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
  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
Last edited on
Topic archived. No new replies allowed.