title: How To Shift Array Elements to right and replace the shifted index with string in Visual C++
body: <p>VISUAL C++ Question</p>
  
  <p>Hi,</p>
  
  <p>I have array of 3 elements and I want to shift its elements to the right and replace the shifted index cell with "SHIFTED" string and this should loop until all the cells has "SHIFTED" string.</p>
  
  <hr>
  
  <p>For example:</p>
  
  <pre><code>int a[x]={0,1,2};
  </code></pre>
  
  <p>Initial index and elements Order:</p>
  
  <pre><code>[0]=0
  [1]=1
  [2]=2
  </code></pre>
  
  <p>should become in the:</p>
  
  <p>1st loop:</p>
  
  <pre><code> [0]=SHIFTED
   [1]=0
   [2]=1
  </code></pre>
  
  <p>2nd Loop:</p>
  
  <pre><code> [0]=SHIFTED
   [1]=SHIFTED
   [2]=0
  </code></pre>
  
  <p>3rd Loop:</p>
  
  <pre><code> [0]=SHIFTED
   [1]=SHIFTED
   [2]=SHIFTED
  </code></pre>
  
  <p>I know I can do that with memmove() but I don't want to use any function in it.</p>
  
  <p>Would you please help me; here is my work:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;stdio.h&gt;
  #include &lt;cstdlib&gt;
  using namespace std;
  
  int const ARRAY_SIZE=3;
  
  int main()
  {
   int Array[ARRAY_SIZE];
   int iniPostion,newPostion;
   string x="SHIFTED";
   for(iniPostion=0; iniPostion&lt;ARRAY_SIZE; iniPostion++)
   {
    Array[iniPostion] = iniPostion;
    cout &lt;&lt; "Cell [" &lt;&lt; iniPostion &lt;&lt; "] Initial Element is: (" &lt;&lt; Array[iniPostion] &lt;&lt; ")" &lt;&lt; endl;
   }
   cout &lt;&lt; endl;
   for(newPostion=0; newPostion&lt;ARRAY_SIZE; newPostion++)
   {
    Array[newPostion]=newPostion;
    cout &lt;&lt; "Cell [" &lt;&lt; newPostion &lt;&lt; "]     New Element is: (";
    if(Array[newPostion-1]&lt;0)
    {
     cout &lt;&lt; x &lt;&lt; ")\n";
    }
    else
    {
     cout &lt;&lt; Array[newPostion-1] &lt;&lt; ")" &lt;&lt; endl;
    }
   }
   return 0;
  }
  </code></pre>