1.

stremp फंक्शन का उपयोग किये बिना दो स्ट्रिंग की तुलना (Comparison) किस प्रकार की जाती है? उदाहरण सहित बताइए।

Answer»

strcmp() is a built-in library function and is declared in header file. This function TAKES two strings as arguments and compare these two strings lexicographically.

// C program to illustrate

// strcmp() function

#include

#include

int main()

{

CHAR leftStr[] = "g f g";

char rightStr[] = "g f g";

// Using strcmp()

int res = strcmp(leftStr, rightStr);

if (res==0)

PRINTF("Strings are equal");

else

printf("Strings are unequal");

printf("\nValue returned by strcmp() is: %d" , res);

RETURN 0;



Discussion

No Comment Found