title: Passing user input to function with char* parameters
body: <p>I get the following errors with my code.</p>
  <blockquote>
  <p>cannot convert parameter 1 from 'std::string' to 'char *</p>
  <p>no operator found which takes a right-hand operand of type 'const char *</p>
  </blockquote>
  <p>Can someone tell me what I'm doing wrong in the menuSelection function below?  The point of it is if a user selects 1 from the menu options, the program gets user input (lastName, firstName, courseName, letterGrade) and passes it to the addRecord function but I think my data types are off.</p>
  <p>Sorry for the long post.  The menuSelection function is towards the bottom right about the main() and head() functions.</p>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;string&gt;
  #include &lt;sstream&gt;
  
  using namespace std;
  
     
  void GradeBook::addRecord(char* lastName, char* firstName, char* className, char letterGrade)
  {
      StudentRecord* newRecord = new StudentRecord(lastName, firstName, className, letterGrade);
      if (_headRecord == NULL) {
          _headRecord = newRecord;
      } else { 
          int compare = _headRecord-&gt;compareTo(lastName, firstName);
          if (compare &lt; 0) {
              // we insert before the first element
              newRecord-&gt;setNext(_headRecord);
              _headRecord = newRecord;
          } else {
              _headRecord-&gt;insert(newRecord);
          }
      }
  }
  
    void menuSelection(int selection, GradeBook&amp; gradeBook) {
  
      string firstName;
      string lastName;
      string courseName;
      char letterGrade;
  
      switch(selection) {
          case 1: cin &gt;&gt; lastName.c_str() &gt;&gt; firstName.c_str() &gt;&gt; courseName.c_str() &gt;&gt; letterGrade;
                  gradeBook.addRecord(lastName, firstName, courseName, letterGrade);
          case 4: gradeBook.read(&quot;students.txt&quot;);
                  gradeBook.displayAllRecords();
                  break; 
          case 5: gradeBook.write(&quot;students1.txt&quot;);
                  break; 
          default: cout &lt;&lt; &quot;Enter a valid choice.\n&quot;; 
          } 
  
          if (selection != 5) {
              displayMenu();
              cin &gt;&gt; selection; 
              menuSelection(selection, gradeBook);
          }
  } 
  
  void header() {
      cout &lt;&lt; &quot;STUDENT GRADEBOOK AND GPA CALCULATOR\n&quot;;
      cout &lt;&lt; &quot;=====================================\n&quot;;
  }
  
  void main()
  {
      GradeBook gradeBook;
  
      int userSelection;
      header();
      displayMenu();
      cin &gt;&gt; userSelection; // get the user input for menu selection
      menuSelection(userSelection, gradeBook);
      
      char pause;
  
      std::cin &gt;&gt; pause;
  }
  </code></pre>