arrays.. what is the difference between these two evaluations ?

gives me the same output of input value at index 0 =9

1
2
3
4
   int inputVal = 9
   int itemsRead =0;
   array.resize( array.size( ) * 2 + 1 ) ;
   array[ itemsRead++ ] = inputVal;


1
2
3
4
   int inputVal = 9
   int itemsRead =0;
   array.resize( array.size( ) * 2 + 1 ) ;
   array[ itemsRead ] = inputVal;
Last edited on
The only difference will be the value of itemsRead after the snippets. After the first snippet itemsRead will be 1 and after the second itemsRead will be zero.

so it adds up after assigning it to array[0] ??
In the first, 'itemsRead' is incremented after 9 is assigned to the 0th index.
In the second, 'items'Read' remains a 0 even after the assignment.
Topic archived. No new replies allowed.