Q. Which function is used to compare two strings in C?

  • (A) strcmp()
  • (B) strcmpi()
  • (C) compare()
  • (D) cmpi()
πŸ’¬ Discuss
βœ… Correct Answer: (A) strcmp()
Explanation: The function strcmp() is used to compare two strings in C language.

The strcmp() is a built-in library function and is declared in <string.h> header file. This function takes two strings as arguments and compare these two strings lexicographically.

Syntax:

int strcmp(const char* str1, const char* str2);
Explanation by: Chandani
The function strcmp() is used to compare two strings in C language.

The strcmp() is a built-in library function and is declared in <string.h> header file. This function takes two strings as arguments and compare these two strings lexicographically.

Syntax:

int strcmp(const char* str1, const char* str2);

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
201
Total Visits
πŸ“½οΈ
3 y ago
Published
πŸŽ–οΈ
Chandani
Publisher
πŸ“ˆ
97%
Success Rate