In your function
readArray()
there is the array
check
. You also have the
size
of that array, which really represents its maximum capacity. You need another number which will represent the
count of how many numbers are currently stored in the array. At the start that will be zero.
After reading a number from the file, search the current contents of the array (subscripts from 0 to count-1). If the number is already present, just continue to read the next number from the file. However if it is not there, store it in the array (provided the capacity was not exceeded) and increment the count. After reading/testing/storing all the numbers. just loop through the array and write out its contents.
By the way, in your current code you have the number 100 three times, at lines 28, 30, 34. That's not the best way to handle this. If the number ever needed to change, you'd have to search through the code looking for all the places which needed to be changed. Instead, use a constant.
|
const int arraysize = 100;
|
(choose whichever name you prefer).
Then use that constant when defining the array at line 28 and calling the function at line 34.