title: Segmentation fault when reading C-style string from scanf
body: <p>I have following simple code: </p>
  
  <pre><code>#include &lt;cstdio&gt;
  #include &lt;queue&gt;
  #include &lt;iostream&gt;
  
  struct Pacient {
  int ill_state;
  int ev_num;
  bool operator==(const Pacient&amp; other) const {
      return ill_state == other.ill_state &amp;&amp; ev_num == other.ev_num;
  }
  bool operator&lt;(const Pacient&amp; other) const {
      return (ill_state &lt; other.ill_state) || (ill_state == other.ill_state &amp;&amp; ev_num &gt; other.ev_num); // má menšiu prioritu, ak čaká kratšie (vyššie číslo na kartičke pri vstupe do ambulancie
  }
  bool operator&gt;(const Pacient&amp; other) const {
      return (ill_state &gt; other.ill_state) || (ill_state == other.ill_state &amp;&amp; ev_num &lt; other.ev_num);
  }
  };
  
  int main() {
  char* ccmd;
  std::priority_queue&lt;Pacient&gt; ps;
  int ev_num, ill_state;
  while (std::scanf("%s", ccmd)) {
      std::string cmd(ccmd);
      if (cmd == "dalsi") {
          if (ps.empty()) {
              std::printf("-1\n");
          } else {
              std::printf("%d\n", ps.top().ev_num);
              ps.pop();
          }
      } else if (cmd == "pacient") {
          std::scanf("%d%d\n", &amp;ev_num, &amp;ill_state);
          Pacient new_ps;
          new_ps.ev_num = ev_num;
          new_ps.ill_state = ill_state;
          ps.push(new_ps);
      } else if (cmd == "koniec") {
          break;
      }
  }
  return 0;
  }
  </code></pre>
  
  <p>After compiling and entering something to stdin, I have got following segfault:</p>
  
  <pre><code>       Program received signal SIGSEGV, Segmentation fault.
  __strlen_sse2_pminub () at ../sysdeps/x86_64/multiarch/strlen-sse2-pminub.S:38
  38  ../sysdeps/x86_64/multiarch/strlen-sse2-pminub.S: No such file or directory.
  </code></pre>
  
  <p>I am using Ubuntu 13.10 64-bit.
  Could somebody please explain, what caused the problem?</p>
  
  <p><strong>Note: I am using scanf instead of cin, because I have specific instruction (from school) to use scanf, printf instead of cin, cout. I wouldn't use it otherwise.</strong></p>