title: How to input a string from a structure using getline?
body: <p>Im currently going through C++ Basics in data structure and have a small doubt regarding strings</p>
  <p>I am trying to input a string value from the main function by creating an instance of a structure object in the main function.</p>
  <pre><code>#include&lt;iostream&gt;
  #include&lt;sstream&gt;
  #include&lt;string&gt;
  
  using namespace std;
  
  struct StudentData {
    string name[50];
    char rollNo[20];
    int semester;
  };
  
  int main() {
    struct StudentData s1;
    cout&lt;&lt;&quot;Enter the name, Roll.No and Semester of the student:&quot;&lt;&lt;endl;
    getline(cin, s1.name);
    cin&gt;&gt;s1.rollNo&gt;&gt;s1.semester;
    cout&lt;&lt;endl&lt;&lt;&quot;Details of the student&quot;&lt;&lt;endl;
    cout&lt;&lt;&quot;Name: &quot;&lt;&lt;s1.name&lt;&lt;endl;
    cout&lt;&lt;&quot;Roll.No: &quot;&lt;&lt;s1.rollNo&lt;&lt;endl;
    cout&lt;&lt;&quot;Semester: &quot;&lt;&lt;s1.semester&lt;&lt;endl;
    return 0;
  }
  </code></pre>
  <p>But here I am getting error in getline for name.</p>
  <pre><code>mismatched types 'std::__cxx11::basic_string&lt;_CharT, _Traits, _Alloc&gt;' and 'std::string [50]' {aka 'std::__cxx11::basic_string&lt;char&gt; [50]'}
  </code></pre>
  <p>Could you please explain what is happening here?
  Thank you</p>