title: terminate called after throwing an instance of 'std::invalid_argument' what(): stoi
body: <p>stoi function crashes program with the error message </p>
  
  <pre><code>"****@****:~&gt; g++ -std=c++0x m1.cpp stimulation.h stims.h Task.h exoskeleton.h ARAIG_Sensors.h Profile.h
  
  ARAIG_Sensors.h:1:9: warning: #pragma once in main file [enabled by default]
  
  Profile.h:1:9: warning: #pragma once in main file [enabled by default]
  
  *****@****:~&gt; a.out StimulationConfig.csv TaskConfiguration.csv SampleProfileConfig.csv SampleOutput.txt
  
  First : a.out
  Second : StimulationConfig.csv
  terminate called after throwing an instance of 'std::invalid_argument'
    what():  stoi
  Aborted
  </code></pre>
  
  <p>and I can't figure out why, there is a instance being passed into the function but still returning an error. Can someone please help me out with a solution maybe?</p>
  
  <pre><code>#pragma once
  #include &lt;string&gt;
  #include &lt;vector&gt;
  #include "Task.h"
  #include &lt;ostream&gt;
  #include "ARAIG_Sensors.h"
  namespace m1
  {
      class Profile
      {
          ARAIG_Sensors araig;
          std::vector&lt;Task&gt; ToRun;
          std::vector&lt;Task&gt; Completed;
          std::string studentFN;
          std::string studentLN;
          std::string studentSN;
          std::string flightFN;
          std::string flightLN;
          std::string flightEN;
          std::ostream&amp; os;
  
          struct calibration {
              int Max;
              int Min;
          };
  
          calibration cal;
  
      public:
          Profile(std::string fn, std::ostream&amp; o, ARAIG_Sensors&amp; a) : os(o)
          {
              araig = a;
  
              //parsing student
              std::ifstream infile(fn);
              std::string line;
              std::getline(infile, line);
              int f = line.find_first_of(",");
              studentFN = line.substr(0, f);
              line = line.substr(f + 1);
              f = line.find_first_of(",");
              studentLN = line.substr(0, f);
              studentSN = line.substr(f + 1);
  
              //parsing flight
              std::getline(infile, line);
              f = line.find_first_of(",");
              flightFN = line.substr(0, f);
              line = line.substr(f + 1);
              f = line.find_first_of(",");
              flightLN = line.substr(0, f);
              flightEN = line.substr(f + 1);
  
              //parsing calibration
              std::getline(infile, line);
              f = line.find_first_of(",");
              cal.Min = stoi(line.substr(0, f));
              std::cout &lt;&lt; cal.Min &lt;&lt; std::endl;
              line = line.substr(f + 1);
              cal.Max = stoi(line);
  
  
  
              std::list&lt;Task&gt; temp = araig.gettasks();
              while (std::getline(infile, line))
              {
                  for (std::list&lt;Task&gt;::iterator i = temp.begin(); i != temp.end(); i++)
                  {
                      if ((*i).getName() == line)
                      {
                          ToRun.push_back(*i);
                          break;
                      }
  
  
  
                  }
  
              }
  
          }
          void displayToRun()
          {
              for (std::vector&lt;Task&gt;::iterator i = ToRun.begin(); i != ToRun.end(); i++)
              {
                  (*i).execute(os);
              }
          }
          void displayCompleted()
          {
              for (std::vector&lt;Task&gt;::iterator i = Completed.begin(); i != Completed.end(); i++)
              {
                  (*i).execute(os);
              }
          }
          void displayNext()
          {
              std::vector&lt;Task&gt;::iterator i = ToRun.begin();
              (*i).execute(os);
          }
          void displayLast()
          {
              std::vector&lt;Task&gt;::iterator i = Completed.end();
              (*i).execute(os);
          }
          void Run()
          {
              //excute next Task and move Task to Completed
              std::vector&lt;Task&gt;::iterator i = ToRun.begin();
              Task t = *i;
              t.execute(os);
              ToRun.erase(i);
              Completed.push_back(t);
          }
      };
  
  }
  </code></pre>