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

Answer Posted / premkumar

#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 ?    69 Yes 24 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the meaning of typedef struct in c?

776


List out few of the applications that make use of Multilinked Structures?

1673


What is sizeof in c?

738


What does 3 periods mean in texting?

766


how to count no of words,characters,lines in a paragraph.

4109






What are the back slash character constants or escape sequence charactersavailable in c?

893


Can we access the array using a pointer in c language?

758


What are header files and what are its uses in C programming?

809


Write a program to swap two numbers without using third variable?

1011


What is pointer to pointer in c language?

760


Explain union. What are its advantages?

789


in any language the sound structure of that language depends on its a) character set, input/output function, its control structures b) character set, library functions, input/output functions its control structures c) character set, library functions, control sturctures d) character set, operators, its control structures

888


How are portions of a program disabled in demo versions?

975


Explain what is the difference between the expression '++a' and 'a++'?

831


Explain what are binary trees?

796