I have a question about loading values into an array. Let's say that I have an initialized array of length n, and that I want to read in new values. For example lets say that the array is initialized to all zeros. Now I want to read in - n numbers or characters,but after I do that if an element contains the same element that want to read in I have to prevent it from occurring. For example:Code:ary[n] = {0}
let's say that the array is of length five.
I did not fill the whole array with 'M', now let's say that this same array is called again and I want to fill the rest of the array with 'M',but If an 'M' is already in an index position I wan't to prevent an 'M' from overwriting a previous 'M' and just look for a place with no 'M' and put one there. How could I do this?Code:int i; char ary[5]= {0} for(i= 0;i<3;i++){ ary[i] = 'M'; }