August 2, 2016

Comparing String without using the function (strcmp)

 Comparing String without using the function (strcmp)

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
void main()
{
 clrscr();
 char a[80],b[80];
 int i=0,j=0,flag=0,len,l;
 cout<<"Enter first string :\t";
 gets(a);
 cout<<"Enter second string :\t";
 gets(b);
  while(a[i]!='\0')
   {
     len++;
     i++;
    }
  while(b[j]!='\0')
  {
     l++;
     j++;
   }
   for(i=0,j=0;a[i]!='\0'||b[j]!='\0';i++,j++)
   {
     if((int)a[i]>(int)b[j])
     {flag=1;break;}
      else
      if((int)a[i]<(int)b[j])
     {flag=2;break;}
    }
    if(flag==1)
    cout<<"1";
    else
    if(flag==2)
    cout<<"-1";
    else
    cout<<"0";
    getch();
  }

1 comment:

  1. Do you need to increase your credit score?
    Do you intend to upgrade your school grade?
    Do you want to hack your cheating spouse Email, whatsapp, Facebook, instagram or any social network?
    Do you need any information concerning any database.
    Do you need to retrieve deleted files?
    Do you need to clear your criminal records or DMV?
    Do you want to remove any site or link from any blog?
    you should contact this hacker, he is reliable and good at the hack jobs..
    contact : cybergoldenhacker at gmail dot com

    ReplyDelete

Disqus Shortname

Comments system