223k views
3 votes
The strcmp(string1,string2) function compares string1 to string2. it is a value returning function that returns a negative integer if string1 < string2, 0 if string1.

a) A positive integer
b) A zero
c) A string
d) An error code

User Akamaozu
by
8.1k points

1 Answer

4 votes

Final answer:

The strcmp() function compares two strings and returns a negative integer if string1 is less than string2, 0 if both strings are equal, and a positive integer if string1 is greater than string2.

Step-by-step explanation:

The strcmp(string1, string2) function in programming is used to compare two strings lexicographically. If string1 is less than string2, the function will return a negative integer. If string1 is equal to string2, it will return 0. If string1 is greater than string2, then the function will return a positive integer.

These integer values are often used to determine the sort order of strings in a program. No error code is returned by strcmp(); it strictly returns an integer based on the comparison.

User Sachin Thampan
by
7.9k points
Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.