title: How to scan a string using scanf with C++
body: <p>I have tried most of the string and char format types and they are not working and I have no Idea why. Here is my code : </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;stdio.h&gt;
  
  using namespace std;
  int main(int argc, const char * argv[])
  {
  
      // insert code here...
      string string2;
      string string;
  
      cout &lt;&lt; "Hello, World!\n";
      printf("Hi my name is Josh %s\n",string2);
      scanf("%s",&amp;string);
      printf("hi %s",string);
  }
  </code></pre>