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 is the general form of function in c?

761


What is c language in simple words?

786


How do you convert a decimal number to its hexa-decimal equivalent.Give a C code to do the same

837


Explain what is gets() function?

786


‘ C’ PROGRAME TO SHOW THE TYPE OF TRANGLE BY ACCEPTING IT’S LENGTH .

2547






Explain which of the following operators is incorrect and why? ( >=, <=, <>, ==)

763


Explain low-order bytes.

789


Why do some versions of toupper act strangely if given an upper-case letter?

800


Write a program to input the price of 1 burger and the number of burgers eaten by a group of friends .print the total amount to be paid by the group?

747


c language supports bitwise operations, why a) 'c' language is system oriented b) 'c' language is problem oriented c) 'c' language is middle level language d) all the above

785


What is declaration and definition in c?

706


which of the following is allowed in a "C" arithematic instruction a) [] b) {} c) () d) none of the above

1349


explain what are actual arguments?

798


What is a 'null pointer assignment' error? Explain what are bus errors, memory faults, and core dumps?

921


Is int a keyword in c?

717