String Comparison with string function

Thursday, 8 September 2011

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char str1[]="Aakash";
char str2[]="Harsha";
int c;
clrscr();
c=strcmp(str1,str2);
if(c>0)
 {
   printf("string 1 is greater");
 }
else
{
  if(c<0)
   {
     printf("String 2 is greater");
   }
  else
   {
     printf("Equal");
   }
}
getch();
}


OUTPUT:


String 2 is greater









No comments:

Post a Comment

 

Blogger news

Blogroll

Enter your email address:

Delivered by FeedBurner

Total Pageviews

Followers

Most Reading