title: Read from a file then convert from to int?
body: <p>I wrote this function that is supposed to read from a file containing ACII decimal numbers and convert these to integers stored in an int array. Here is that function:</p>
  
  <pre><code>void readf1()
  {
      int myintArray[100];
      int i = 0;
      int result;
      string line = "";
      ifstream myfile;
      myfile.open("f1.txt");
  
      if(myfile.is_open()){
        //while not end of file
        while(!myfile.eof()){
          //get the line
          getline(myfile, line);
  
          /* PROBLEM HERE */
          result = atoi(line);
  
          myintArray[i] = result;
          //myintArray[i]
          cout&lt;&lt;"Read in the number: "&lt;&lt;myintArray[i]&lt;&lt;"\n\n";
          i++;
       }
    }
  }
  </code></pre>
  
  <p>The problem is that atoi is not working. The error I get is <code>cannot convert 'std::string {aka std::basic_string&lt;char&gt;}' to 'const char*' for argument '1' to 'int atoi(const char*)'</code>. I'm not sure why its not working as I looked at examples and I am using it exactly the same. Anyone know what I may be doing wrong?</p>