Hi, I need to compare two numbers.
If the numbers are not made out of the same number of digits strcmp() will return 0 meaning that they are equal.
strncmp() will return the correct answer 1, meaning the first number is greater.
Is there a work around with strcmp() that it returns the correct result too?
Code:#include <iostream>
using namespace std;
int main()
{
int ret = strcmp("1 222 111", "1 222 11");
cout << "Result: " << ret << "\n";
ret = strncmp("1 222 111", "1 222 11", 9);
cout << "Result: " << ret << "\n";
system("pause");
return 0;
}