Compare numbers version1 and version2.
If version1 > version2 return 1, if version1 < version2 return-1, otherwise ret Urn 0.
Assume that the version strings is non-empty and contain only digits and the . character.
The . character does not represent a, decimal point and was used to separate number sequences.
For instance, was not "both and 2.5 a half" or "half-to-version three", it is the fifth Second-level revision of the S Econd first-level revision.
Here are an example of version numbers ordering:
0.1 < 1.1 < 1.2 < 13.37
intCompareversion (Char* Version1,Char*Version2) { intV1 =0, V2 =0; while(*version1 | | *Version2) { while(*version1 && *version1! ='.') {v1= V1 *Ten+ *version1-'0'; Version1++; } while(*version2 && *version2! ='.') {v2= V2 *Ten+ *version2-'0'; Version2++; } if(V1 >v2)return 1; Else if(V2 >v1)return-1; Else { if(*version1) Version1++; if(*version2) Version2++; V1= V2 =0; } } return 0;}
- Disgusting topic, will appear 1.0.1
Compare Version Numbers