1) Populate the first uniqueString[] with the first symbol
2) for every line in the file
3) Scan uniqueString[]
4) If match found, increase counter array by 1
5) If not found by end of the uniqueString[] , add to last spot
6) Once whole uniqueString[] full up, assign symbols and replace those lines in File1.

From what I've debugged, It adds the first symbol 0:0:0 to uniqueString[0].

And scans through rest, Breaking out if same 0:0:0, but counter doesn't increase, and after it passes 0:0:0 it doesn't add the next string 0:0:10.

I'm sure I'm just being stupid here, But anything I'm blatantly missing? I know point 6 won't work, as that's not implemented yet.

Your algorithm is incorrect. When you read in a string, you need to check
the whole array if the string exist. I suggest you use a map, to store the
the value as a key, then you won't have to much work since the map
automatically does not add elements with the same key. What do you think?

Your algorithm is incorrect. When you read in a string, you need to check
the whole array if the string exist. I suggest you use a map, to store the
the value as a key, then you won't have to much work since the map
automatically does not add elements with the same key. What do you think?

Mmm why do you think it doesn't? O.o

for(int arraycell = 0; arraycell < 10; arraycell++) {

Should search from uniqueString[0] to uniqueString[9], which would be the entiraty of the array, or am I being stupid?

Thanks Lilly

* ps - Edit or is it that second break statement?

* Edit 2 - In terms of the map the problem I had was that if it automatically ignores that value, I wouldn't be able to increase the counter. As the sorted file is just purely for counting, I need to edit the original file by replacing the "most" common values.

Post code used to display uniqueString[] and indicate if the code is in main() or in a function. Also, where is uinqueString[] declared relative to it's being displayed----same or different function?

Between line 6 and 7 of my post you could output lineRead to be sure you're getting something with the read each time through the loop which should ensure something being entered into loop to work with.

Line 32 shouldn't use 10 as the terminating value of the loop as uniqueString could have a single unique string if all inputs are the same, 10 uniques strings if inputs are all different, or someplace in between. You only want to display the actual number of unique strings.

Between line 15 and 16 put an output statement and a pause to see what the actual input is.

cout << "this line is " << lineRead << endl;
cin.get();

This is called debugging code and should be removed once you've isolated the problem. It is a very powerful technique for trying to answer questions like this. If you are comfortable using a debugger the process is (somewhat) automated for you.

Line 32 shouldn't use 10 as the terminating value of the loop as uniqueString could have a single unique string if all inputs are the same, 10 uniques strings if inputs are all different, or someplace in between. You only want to display the actual number of unique strings.

Between line 15 and 16 put an output statement and a pause to see what the actual input is.

cout << "this line is " << lineRead << endl;
cin.get();

This is called debugging code and should be removed once you've isolated the problem. It is a very powerful technique for trying to answer questions like this. If you are comfortable using a debugger the process is (somewhat) automated for you.

Sorry, Maybe I explained this badly. I do debug the code here, Just remove all my couts when posting code.

The read in works fine, Every line of the file is read through, and there's roughly 55,000 duplicated lines (out of 200k+ total lines), so the 10 was just a test to see if the code was working.

The problem is that the array that's set to store the value of how many times a single line is repeated only ever stores the one value.

Whether this is 0:0:0 or 99:99:99 it will only ever store one.

This is why I was referring to the same problem I had with my code as yours, as it's not filling up the array with the different duplicated codes, only the "last" duplicated.

Duh, my bad. If a unique string is identified then numUnique needs to be increased in addition to the unique string being entered into uniqueStrings. In post #4, between line 17 and 19 put a line that looks something like this: