Write a program to compare two strings without using the
strcmp() function

Answer Posted / vijay.benzamin

#include<iostream.h>
#include<stdio.h>
#include<conio.h>
void main()

{
clrscr();
int c=0;
char a[10];

char b[10];
gets(a);
gets(b);
for(int i=0,j=0;b[i]!='\0'||a[j]!='\0';i++,j++)
{
if(a[i]!=b[j])
{
c++;

}

}
if(c==0)
cout<<"string match";
else
cout<<"string does not match";

getch();
}

Is This Answer Correct ?    54 Yes 31 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What do you mean by a sequential access file?

629


What is the function of volatile in c language?

668


Linked list is a Linear or non linear explain if linear how it working as a non linear data structures

1764


what is diffrence between linear and binary search in array respect to operators?what kind of operator can be used in both seach methods?

1455


What is a pointer value and address in c?

636






What is the size of enum in c?

624


Why does the call char scanf work?

620


What is exit() function?

561


What are the 5 types of organizational structures?

550


Explain the use of 'auto' keyword in c programming?

683


Explain is it better to bitshift a value than to multiply by 2?

718


What are the modifiers available in c programming language?

742


hai iam working in sap sd module for one year and working in lumax ind ltd in desp department but my problem is i have done m.b.a in hr/marketing and working sap sd there is any combination it. can you give right solution of my problem. and what can i do?

1665


Is main a keyword in c?

632


Tell me what is null pointer in c?

615