title: wait for user input while debugging Rcpp
body: <p>When debugging Rcpp, I usually find myself having to use old-school Rprintf statements to watch variables and program flow (as per the comment from @RomainFrancois on <a href="https://stackoverflow.com/a/21229530/2761575">this answer</a>).  However, for situations such as large loops, where too much rapid output from Rprintf can quickly disappear over the top of the console, I would like to be able to pause execution until I press a key.</p>
  
  <p>If I try using a <code>std::cin.get()</code> call in the c++ script and running it from Rstudio, the console gets stuck with no obvious way to direct keystrokes to the c++ call that is awaiting them. NB this is an RSudio specific problem - it does not occur when running the same code from a terminal window, which works as expected.</p>
  
  <p>A simple reproducible example:</p>
  
  <pre><code>library(Rcpp)
  
  cppFunction('
  void test() {
    for (int i = 0; i &lt; 100; i++) {
      Rprintf(\"i = %i\\n\", i);
      std::cin.get();
    }
  }
  ')
  
  test()
  </code></pre>
  
  <p>How can I get this to work so I can step through Rcpp functions interactively to debug them?</p>