Array Question
I'm working on reducing some redundant code segments and ran across something that I'm curious about.
In my mod, I have 5 elements and initialize my array as <type> myarray[5] = {arg1, arg2, arg3, arg4, arg5}. I reference it using a zero-based index and everything works just fine. However, I ran across this snippet and can't figure out why it's coded this way. Code:
const char *message_arg[9] = {0}; Each message# is passed as a parameter into the function. Thanks! |
i++ is known as a post-increment. That means it saves the initial value, increments it, then returns the initial value. By comparison, ++i simply increments the value and returns it. This is why the pre-increment is preferred when using iterators, since it potentially avoids a copy.
Based on that description you can probably figure out what that code does. Of course, you could also figure out what it does based on the fact that it doesn't corrupt the stack which it would if it was starting at index 1. |
That makes sense! Thanks!
I'm still trying to convert what little I know about VB into VC++, so I miss some basic concepts more often than not... |
All times are GMT -4. The time now is 02:27 AM. |
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.