Comments

Wednesday, October 17, 2012

Compare two array without using strcmp()

Posted by at 8:47 AM Read our previous post


Object
1-      Compare two array without using strcmp()


Source code

#include <iostream>
using namespace std;
void main()
{
       int a=0,str=0,str1,num=5;
       char array1[]="king";
       char array2[]="joker";
      


       for(str=0;str<25;str++)
       {
       if(array1[str]==array2[str])
       {
              cout<<"Arrays are equal"<<endl;
              break;
       }
       else
              {
                     cout<<"Arrays are not equal"<<endl;
                     break;
              }
       }     
       cout<<"\n";

}

Output

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Popular Posts

Labels

© Codepirate is powered by Blogger - Template designed by Stramaxon - Best SEO Template