Sunday, August 2, 2009

A program in C that uses the string command 'strcmp'?

Please provide me a sample program that implements the string function 'strcmp'. I really need this program. Thank you.

A program in C that uses the string command 'strcmp'?
strcmp() is a function that compare the two string. If both string are same then it return 0 else -1.





The program is as follows:





#include%26lt;stdio.h%26gt;


#include%26lt;string.h%26gt;


int main()


{


char str1[10] = "XYZ";


char str2[10] = "XYZ";


if(strcmp(str1,str2)==0)


{


printf("The string are same\n");


}


else


{


printf("Not equal\n");


}


return 0;


}





output:


The string are same
Reply:Can it help u put


http://www.koders.com/c/fid12C8C85975AEE...

forsythia

No comments:

Post a Comment