my programme has the strcmp. but i dont understand what it is use for.


bed_num and beddelete i have declared as an integer variables. when i run the programme, it stated that

invalid conversation from 'int' to 'const char*'

what does it mean??

thank you

The function strcmp(string1, string2) compares the two strings, string1 and string2, and returns an integer:

< 0 (string1 is less than string2)

0 (string1 is identical to string2)

> 0 (string1 is greater than string2)

If you try to compare an integer with a string, you get an error!

What does it mean that a string is greater than the other?
What a kind of comparision do we do?

>What a kind of comparision do we do?
It does a lexical comparison using the integral value of a character:

int i = 0, j = 0;

while ( a[i] == b[j] ) {
  if ( a[i] == '\0' )
    return 0;

if ( a[i] < b[j] )
  return -1;
  return +1;

For example, in ASCII, a < z < A < Z, so test would be "less than" TEST using strcmp.