palindrome

Pages: 12
Thanks for the tips. I did *mean* decrement, but I was in computer programming mode instead of English major mode, and I couldn't think of the word.

You use reverse(n) as an example of another method. This looks like something pretty basic that I've missed. Do you know a good resource for these kinds of operations?

When you say "ISO forbids variable length array," is there a reason for this? Obviously, it works, though in many cases (system, as you pointed out), that doesn't mean much. Given my methodology, would it have been better to simply declare an array of sufficient length (i.e., picking some random number of elements that I'm not likely to accidentally exceed)? Also, does the array I create "go away" after each call to the palindrome function, or should I do something to free up that memory?

As for std:vector/dynamic allocation, they're still a little over my head, but I'll look into them more as soon as the C++ book I reserved at the library comes in.

You say working=(working-(working%10))/10; is equivalent to working /= 10;. Is that only because I'm working with integers?

Finally, I originally had a function to determine number of digits, but when I tried to call it from the palindrome function, my program would hang. That seems odd, because main() is also a function, so calling a function from within another function shouldn't be a problem. Any ideas what I might have done wrong?

Again, thanks for the advice. I'm going to mark this as solved, but I'd still appreciate any feedback you have.
reverse http://www.cplusplus.com/forum/beginner/47260/#msg256584

variable length array http://www.cplusplus.com/forum/general/45467/#msg246744
you only need to delete what you new

Integer division returns an integer.

Dunno what happen with your count_digits function, if you post it we may help.

Regards.
Topic archived. No new replies allowed.
Pages: 12