Trying to decide which programming language I want to learn

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
397 replies · 23K 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.
 
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