Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8716083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:59:29+00:00 2026-06-13T05:59:29+00:00

In a code I have 2 CString which contain a part of version number,

  • 0

In a code I have 2 CString which contain a part of version number,
First exe contain version 1.1234.3.1 and the second exe has version 1.2.3.1.

Code should be such that

Suppose

CString MinVreg,MinFref;

if(MinVreg<MinFref) //when MinVreg="1234" and MinFref="2"

{
    //it enters in if loop.
    //Update registry
}
elseif(MinVreg>MinFref)
{
   //Show message box..
}

I think the operator check only first digit.So please tell me how to compare it as a number

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T05:59:30+00:00Added an answer on June 13, 2026 at 5:59 am

    You have to parse the strings to represent a version as an integer array, then perform a lexicographic compare.

    bool ParseVersionString(unsigned digits[4], const CString& i_version)
      {
      return sscanf(i_version, "%d.%d.%d.%d", &digits[0], &digits[1], 
                    &digits[2], &digits[3]) == 4;
      }
    
    int CompareVersions(unsigned ver1[4], unsigned ver2[4])
      {
      for (int i = 0; i != 4; ++i)
        {
        if (ver1[i] < ver2[i])
          return -1;
        if (ver1[i] > ver2[i])
          return 1;
        }
    
      return 0;
      }
    

    Usage:

      CString MinVreg("1.1234.3.1"), MinFref("1.2.3.1");
      unsigned ver1[4], ver2[4];
      if (ParseVersionString(ver1, MinVreg) &&
          ParseVersionString(ver2, MinFref) &&
          CompareVersions(ver1, ver2) < 0)
      {
      //Update registry
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a code in which Cstring and wchar_t both are used. I think
I have old code that uses size_t which IIRC comes from cstring.h. On OS
If I have code such as class CString { int GetLength(); }; bool smaller(CString
I have code which has a drop down list. And when a certain option
I have written a code which calculates Fibonacci number using my own arbitrary precision
I have a MFC application, which has a worker thread, what I want to
I have downloaded an sample code, so there are some CString variables in that
I have the following code which is an implementation of BPM (bipartite matching, from
I have the following code... which is throwing a main.cpp:18: undefined reference to phrase_init()
I have some code that needs Unicode strings for the most part, but I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.