(I am new to coding) I am trying to replace an array element with itself plus 1, but it does not seem to work. In the following I am trying to replace the 3rd element:
int l=5;
int histogram[l];
histogram[l]={0};
histogram[2] = histogram[2] + 1;
It gives me the following error;
Expected ';' after expression
histogram
histrogram? Where is this line?histogramis, you could dohistogram[2] += 1orhistogram[2]++or++histogram[2].int histogram[5] = {0};. Usingl(a variable not known at compile time) for the size is not supported by the C++ standard and the 3rd line is just odd, you try to assign an array to an integer, mind you it's outside of your array too. In general though, using avectorwould be best.las a variable name, because it can easily be misinterpreted as the number1.