0

Please I am trying to find built in function that compares not the alphabet but the digits in two character array. for example

if in char array1[50] there is a number 500 and in char array2[50] there is a number 100 so I should be able to compare which one is bigger, in this case 500 is bigger which is array1 so what is the built in function for this. Please help me.

Claudiordgz
  • 3,023
  • 1
  • 21
  • 48
user3215228
  • 313
  • 1
  • 3
  • 13

2 Answers2

1

prepend(add '0' at the beginning) '0' so both strings become same in length, then you can use strcmp(), or std::string::compare() depending on your data type.

wacky6
  • 135
  • 3
0

Use boost::lexical_cast:

if (boost::lexical_cast<int>(array1[50]) > boost::lexical_cast<int>(array2[50]))
{
    // array1[50] bigger than array2[50]
}
Paul Evans
  • 27,315
  • 3
  • 37
  • 54