There is no direct way to know how much content you have in an array, versus the size of the array. Except, of course, when your array is of type char and you are using it properly for strings.
Consider an array of integers. Just because some element has a value 0, does that make it an unused element? Zero might well be a valid data value.
Hansels's suggestion to keep track of data as it's entered, and pass that value around along with the array, is about the best general solution.
If I understand what you're doing, when the data is in a string might be a good time to capture the length of the data ( str.size() )
Sounds like an awful lot of work just to reverse the array. Why convert (copy?) from the char array to an int array? Char's are, after all, just small integers.
Reputation Points: 1268
Solved Threads: 228
Posting Virtuoso
Offline 1,895 posts
since Aug 2007