hi
my program is supposd to deleted repeated (identical) array elements within an array. Although its not working but I can figure out why?
Also is there a more advanced way of doing this; checking for repetitions in an array? I am not sure but maybe using stringstream?
I am reading in names from a text file & adding those names to an array, is there a way to read the file + store the names in array without repeats in one go. Instead of; reading the file & storing all names(repeats & all) in an array, then search the array for repeats & store in a new array?
heres my code
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
using namespace std;
int main()
{
string names[7] = { "jim", "mag", "narelle", "jim", "helga", "mag", "kim" };
string array[7];
for (int i = 0; i < 7; i++)
{
for (int j = 0; j < 7; j++)
{
while ( names[i] != array[j] )
{
array[i] = names[i];
}
}
}
//just for debugging.
for (int i = 0; i < 7; i++)
{
cout << names[i] << " ";
}
cout << endl;
for (int i = 0; i < 7; i++)
{
cout << array[i] << " ";
}
return 0;
}