title: Ignoring characters in the input
body: <p>Input:  </p>
  
  <blockquote>
    <p>3</p>
    
    <p>23 + 47 = machula</p>
    
    <p>3247 + 5machula2 = 3749</p>
    
    <p>machula13 + 75425 = 77038</p>
  </blockquote>
  
  <p>I was solving a question in spoj where the input was in the form "string +  string = string". I had to store the first, second and the third numbers in strings skipping the '+' and '='. For that I created two char variables to store the '+' and '='.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  
  int main()
  {
      using namespace std;
      int t;
      cin &gt;&gt; t;
      for (int iii = 0; iii &lt; t; iii += 1)
      {
          cin.ignore();
          int num1, num2, num3;
          int condition = 0;
          string input1;
          cin &gt;&gt; input1;
          if (input1.find("machula") != string::npos)
          {
              condition = 1;
          }
          char op1;
          cin &gt;&gt; op1;
          string input2;
          cin &gt;&gt; input2;
          if (input2.find("machula") != string::npos)
          {
              condition = 2;
          }
          char op2;
          cin &gt;&gt; op2;
          string input3;
          cin &gt;&gt; input3;
          if (input3.find("machula") != string::npos)
          {
              condition = 3;
          }
          switch (condition)
          {
              case 1:
                  num2 = stoi(input2);
                  num3 = stoi(input3);
                  num1 = num3 - num2;
                  break;
              case 2:
                  num1 = stoi(input1);
                  num3 = stoi(input3);
                  num2 = num3 - num1;
                  break;
              case 3:
                  num1 = stoi(input1);
                  num2 = stoi(input2);
                  num3 = num1 + num2;
                  break;
          }
          cout &lt;&lt; num1 &lt;&lt; " + " &lt;&lt; num2 &lt;&lt; " = " &lt;&lt; num3 &lt;&lt; endl;
      }
      return 0;
  }   
  </code></pre>
  
  <p>Is there a better way to ignore the '+' and the '=' in the input along with the whitespaces?</p>