title: address of register variable in C and C++
body: <p>I know the concept of register variable and it's use cases but there are few questions in my mind based on what I have tried. </p>
  
  <ol>
  <li><p>I cannot access the address of a register variable in C though I can do it C++! Why? Is there any issue in accessing the addressing of a register variable?</p></li>
  <li><p>Suppose if I declare a string variable in C++ as register, then where will that variable be stored? What is the point in declaring the storage class of non-numeric data types such as 'string' in C++ to be register??</p></li>
  </ol>
  
  <p><strong>UPDATE:</strong>
  I thought that C++ allows us to fetch the address of a register variable, as I was not getting any error in my program which is as follows:</p>
  
  <pre><code>#include&lt;iostream&gt;
  #include&lt;time.h&gt;
  
  using namespace std;
  
  clock_t beg, en;
  
  int main(){
  
      int j, k=0;
  
      beg=clock();
      for(register int i=0;i&lt;10000000;i++){
          /*if(k==0){
              cout&lt;&lt;&amp;i&lt;&lt;endl;    // if this code is uncommented, then C++ rejects the recommendation to make 'i' as register
              k++;
          }*/
      }
      en=clock();
  
      cout&lt;&lt;en-beg&lt;&lt;endl;
  
      cout&lt;&lt;&amp;j&lt;&lt;endl&lt;&lt;&amp;k;
  
      return 0;
  }
  </code></pre>
  
  <p>What I have observed is, if I make the variable 'i' as register and don't try to print the address using '&amp;i' then C++ accepts the recommendation and stores 'i' in register, this can be infered from running time of for loop which will always be around 4-12 ms if 'i' is in register. But if I try to print address of variable 'i' then though I don't get any error but C++ rejects the recommendation and this can be infered from the time of execution of loop which is always more than 25 if i is not register!!</p>
  
  <p>So, basically I cannot fetch address of a variable with storage class as register in both C as well as C++!! WHY?</p>