Reputation:
I wish to change(assign) the value of an element at an index in an array:
a=array[index];
array[index]=0;
Can this be done in one line, like a post/pre increment?
Upvotes: 1
Views: 147
Reputation: 43
Based from your question, you want to assign the value from the array and put it on a different variable. and then you want to assign something into it in just one line of code.
//I'm assuming that both array and variable a is initialized
array[index] = a + -array[index] + (a = array[index]);
Upvotes: 1