Parsing a line from file : <p>I have a file with the following line:</p>

<pre><code>           numOfItems =          100
</code></pre>

<p>I want to read the line from file and initialize the attribute "numOfItems" to 100. How could I do it, i.e, deleting the unnecessary spaces and read only the values I need?</p>

<p>Also, I have another line which is:</p>

<pre><code>num Of Items = 100
</code></pre>

<p>which I need to parse as error (attributes and values cannot contain spaces).</p>

<p>In the first case I know how to remove the spaces at the beginning, but not the intervening spaces. In second case I don't know what to do.</p>

<p>I thought to use <code>strtok</code>, but couldn't manage to get what I needed.</p>

<p>Please help, thanks!</p>
