Q. Which function is used to compare two strings in C?
β
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);
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);