title: How to parse version number to compare it?
body: <p><strong>SCENARIO:</strong> I have a simple application that checks its RSS feed and looks if there's a newer version available. Thus, I want to check if the current version is less than the one present on the RSS feed. Ideally as simple as:</p>
  
  <pre><code>CURRENTVERSION &lt; updateVersion
  </code></pre>
  
  <p><strong>PROBLEM:</strong> The versioning consists of major.minor.revision.build and I don't know how to parse this into a number to perform the version check.</p>
  
  <p>These are the parameters to compare:</p>
  
  <pre><code>#define CURRENTVERSION = 0,2,5,1
  </code></pre>
  
  <p>The version downloaded from the web is <code>"0.2.6.1"</code> ( as a string).</p>
  
  <p>What would be the best way to check if one is less than the other?</p>
  
  <p>I've tried converting it to a double, but the value becomes 0.2 (only the first . is being parsed, rest is ignored).</p>
  
  <p><strong>CONSTRAINT:</strong> It must not be a solution using .NET libraries as the application must work when no .NET framework is present.</p>
  
  <p><strong>(EDIT)</strong> I settled for the following solution, thanks to Karthik T's answer.</p>
  
  <pre><code>struct Version
  {
      Version(string versionStr)
      {
          sscanf(versionStr.c_str(), "%d.%d.%d.%d", &amp;major, &amp;minor, &amp;revision, &amp;build);
      }
  
      bool operator&lt;(const Version &amp;otherVersion)
      {
          if(major &lt; otherVersion.major)
              return true;
          if(minor &lt; otherVersion.minor)
              return true;
          if(revision &lt; otherVersion.revision)
              return true;
          if(build &lt; otherVersion.build)
              return true;
          return false;
      }
  
      int major, minor, revision, build;
  };
  </code></pre>