Mega Code Archive

 
Categories / C++ / Data Type
 

Strcmp( ) function

#include <stdio.h> #include <string.h> char s1[45] = "test"; char s2[45] = "another test"; int answer;    int main( ) {  answer = strcmp(s1,s2);  if (answer>0)      printf("s1 is greater than s2");  else if (answer==0)      printf("s1 is equal to s2");  else      printf("s1 is less than s2");  return (0); }