title: C++ string input using functions
body: <p>I have wrote a code for taking string from the user in C++. here is the code</p>
  
  <pre><code>#include&lt;iostream&gt;
  #include&lt;string&gt;
  using namespace std;
  string input;
  void enterstring()
  {
      cout&lt;&lt;"\nEnter input: ";
      getline(cin,input);
  
  }
  void displaystring()
  {
      cout&lt;&lt;"\nyour string is "&lt;&lt;input&lt;&lt;endl;
  
  }
  {
      int main()
  {
  int choice=0;
  while(choice!=3)
  {
  
      cout&lt;&lt;"Enter choice: "&lt;&lt;;
            cin&gt;&gt;choice;
      switch(choice)
      {
          case 1: enterstring();
          break;
          case 2: displaystring();
          break;
          case 3: cout&lt;&lt;"\nQuit";
          break;
          default: cout&lt;&lt;"\ninvalid choice try again";
          break;
  
  
      }
      return 0;
  }
  </code></pre>
  
  <p>output of the above code:</p>
  
  <pre><code>Enter choice: 1
  Enter input: 
  Enter choice:
  </code></pre>
  
  <p>the input section is skipped I don't know why where is the problem. Is the logic wrong, problem with syntax anything. when I call function without using while loop etc it's working fine but in this case it's not working. help me.</p>