I'm having trouble writing an array program that deletes duplicate numbers in an array. I can't figure out the code for find the array size. I have the array max set to 25 but my array doesn't have 25 numbers in it. (let's say it only has 10 numbers in it) What would be the C++ code to count only the numbers in the array instead of continuing all the way to 25?

You'll need a second array to hold whether the corresponding elements have been found or not. If you're super-tight on memory (unlikely) you can use bit arrays, but a simple bool array will work just fine.

There's no way to find out what values have or have not been loaded into an array.

You have to keep track of the count of values as you load them.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.