title: What is going on with 'gets(stdin)' on the site coderbyte?
body: <p>Coderbyte is an online coding challenge site (I found it just 2 minutes ago).</p>
  
  <p><a href="https://www.coderbyte.com/editor/guest:First%20Factorial:Cpp" rel="noreferrer">The first C++ challenge</a> you are greeted with has a C++ skeleton you need to modify:</p>
  
  <blockquote>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  using namespace std;
  
  int FirstFactorial(int num) {
  
    // Code goes here
    return num;
  
  }
  
  int main() {
  
    // Keep this function call here
    cout &lt;&lt; FirstFactorial(gets(stdin));
    return 0;
  
  }
  </code></pre>
  </blockquote>
  
  <p>If you are little familiar with C++ the first thing<sup>*</sup> that pops in your eyes is:</p>
  
  <pre><code>int FirstFactorial(int num);
  cout &lt;&lt; FirstFactorial(gets(stdin));
  </code></pre>
  
  <p>So, ok, the code calls <code>gets</code> which is deprecated since C++11 and removed since C++14 which is bad in itself. </p>
  
  <p>But then I realize: <code>gets</code> is of type <code>char*(char*)</code>. So it shouldn't accept a <code>FILE*</code> parameter and the result shouldn't be usable in the place of an <code>int</code> parameter, but ... not only it compiles without any warnings or errors, but it runs and actually passes the correct input value to <code>FirstFactorial</code>.</p>
  
  <p>Outside of this particular site, the code doesn't compile (as expected), so what is going on here?</p>
  
  <hr>
  
  <p><sup>*Actually the first one is <code>using namespace std</code> but that is irrelevant to my issue here.</sup></p>