Trying to decide which programming language I want to learn

Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
397 replies · 24K views
sysprog said:
The compiler would reject the 0++ incrementation directive inside the brackets of the a[0++] expression because 0 is not a variable.
I'll take your word for it but, as long as the context is only iteration and not re-iteration (ie: it doesn't need to be rezeroed), it saves a superflous explicit declaration.
 
Physics news on Phys.org
hmmm27 said:
I'll take your word for it but, as long as the context is only iteration and not re-iteration (ie: it doesn't need to be rezeroed), it saves a superflous explicit declaration.
What's wrong with a[1]?
 
Mark44 said:
C++:
unsigned i = 0;
while (i < dynArr.size())
{         
      num = dynArr[i++];
      count << num << " ";// display all the numbers until the end.         
}
This is of course also a common application for a traditional for-loop:
C++:
for (int i = 0; i < dynArr.size(); i++)
{
    count << dynArr[i] << " ";
}
Or in a modern (post 2011) version of C++, a range-based for-loop:
C++:
for (int num : dynArr)
{
    count << num << " ";
}
 
  • Like
Likes   Reactions: pbuk
pbuk said:
What's wrong with a[1]?
Nothing, if your purpose is to explicitly access the second element in an array. In what context were you comparing it to a hypothetical a[0++] statement ?
 
pbuk said:
What's wrong with a[1]?
hmmm27 said:
Nothing, if your purpose is to explicitly access the second element in an array. In what context were you comparing it to a hypothetical a[0++] statement ?
I believe pbuk was referring to this post of yours, #380:
hmmm27 said:
wouldn't be surprised if a c compiler accepted, and processed properly, something to the effect of a[0++]
There's nothing hypothetical about a[0++]. It just flat won't compile.
 
This thread is getting very long, with just under 400 posts. @yungman, when you have another question, please start a new thread.
 
  • Like
Likes   Reactions: pbuk
Thank guys, my big boss just had a hip replacement yesterday and she's home. I am too busy right now to read the replies right now. I'll get to it later tonight or tomorrow.

thanks
 
I'm closing this thread now. If anyone other than the OP (@yungman) feels the need to reply to a post here, please let me know, and I'll reopen it temporarily.