How do you clear array values (or the entire array) so they're empty?
Printable View
How do you clear array values (or the entire array) so they're empty?
If you're talking about an setting an array of integers so that each element equals 0...then you could use a For Loop, going from 0 to (N - 1), where N is the number of elements, and within the For Loop you can set Element[N] = 0.
What do you mean by empty?
Empty as in no value, it's for a char and an int array, so I can write over it with a smaller string, but not have the end of the old one print out.
You can use memset for char or int arrays, but if you're using C++ you should be using strings or vectors which have clear() methods.
would setting all of their values to 0 not be good enough?