title: c++ getline and ignore
body: <p>Can anyone please, tell me why does the following code works, when I use <strong>cin.ignore(0,'\n')</strong> but not when I use <strong>cin.ignore(100, '\n')</strong> :/</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  
  main () {
    char arr[100], brr[100];
    string srr;
  
    cout &lt;&lt; "Enter a string : ";
    cin.clear();
    cin.ignore(0, '\n');
    cin.getline(arr, 100);
    cin.getline(brr, 100);
    cout &lt;&lt; "brr : " &lt;&lt; brr &lt;&lt; endl;
    srr = string(arr);
    cout &lt;&lt; "Converted to string : " &lt;&lt; srr &lt;&lt; endl;
    string find;
    cout &lt;&lt; "Enter something to find : ";
    getline(cin, find);
    cout &lt;&lt; endl;
    if (srr.find(find) != string::npos)
      cout &lt;&lt; "Found ! at " &lt;&lt; srr.find(find) &lt;&lt; " " &lt;&lt; endl;
    else
      cout &lt;&lt; "Sorry ! not found :/ \n";
  }
  </code></pre>