//program to understand strcmp(), libraray function
//strcmp() function
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
clrscr();
char first[50],sec[50];
int k;
gets(first);
gets(sec);
k=strcmp(first,sec);
printf("k=%d",k);
if(k==0)
{
printf("both are same");
}
else if(k>0)
{
printf("first string =%s has more value\n",first);
}
else if(k<0)
{
printf("second string =%s has more value\n",sec);
}
getch();
}
//strcmp() function
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
clrscr();
char first[50],sec[50];
int k;
gets(first);
gets(sec);
k=strcmp(first,sec);
printf("k=%d",k);
if(k==0)
{
printf("both are same");
}
else if(k>0)
{
printf("first string =%s has more value\n",first);
}
else if(k<0)
{
printf("second string =%s has more value\n",sec);
}
getch();
}
No comments:
Post a Comment