title: I have to reverse a string but my code is not producing any output -- C++
body: <p>Given a string S as input. I have to reverse the given string.</p>
  
  <p>Input: First line of input contains a single integer T which denotes the number of test cases. T test cases follows, first line of each test case contains a string S.</p>
  
  <p>Output: Corresponding to each test case, print the string S in reverse order.</p>
  
  <p>why my code is not producing any output?
  I did this:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include&lt;string&gt;
  using namespace std;
  
  int main() {
      int t;
      cin&gt;&gt;t;
      while(t--){
        string s;
        int j=0;
        string res;
        cin&gt;&gt;s;
        int l=s.length();
        for(int i=l-1;i&gt;=0;i--)
        {
           res[j]=s[i];
           j++;
        }
        cout&lt;&lt;res&lt;&lt;endl;
      }
      return 0;
  }
  </code></pre>
  
  <p>input:</p>
  
  <p>1</p>
  
  <p>geeks</p>
  
  <p>output:</p>