reading 2 columns from txt file
<p>I'm writing an small program in C++ and have an input file and need to read line by line, there're 2 columns in file, string name and integer number. for example:</p>

<pre><code>abad 34
alex 44
chris 12
</code></pre>

<p>I wrote such code:</p>

<pre><code>ifstream input("file.txt");
int num;
string str;

while( getline( input, line ) ){
  istringstream sline( line );
  if( !(sline&gt;&gt;str&gt;&gt;num) ){
     //throw error
  }
  ...
}
</code></pre>

<p>I need to throw errors in cases:</p>

<p>if there's no number - only name is written e.g. <code>abad</code> (actually I'm getting error with my code),</p>

<p>if there's a name and no number, e.g.: <code>abad 34a</code>(letter a in <code>34a</code> is ignored and transferred to just 34 in my code while error should be triggered), </p>

<p>or if there're more than 2 columns e.g. <code>abad 34 45</code> (2nd number is ignored).</p>

<p>How to read correctly input data ( and without iterators )?</p>
