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

Sir i need notes for structure,functions,pointers in c language can you help me please

1933


Why is it important to memset a variable, immediately after allocating memory to it ?

1540


Is c easy to learn?

550


Can a program have two main functions?

559


write a program in c language to print your bio-data on the screen by using functions.

6230






Can you please explain the difference between syntax vs logical error?

680


Write a C/C++ program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the maximum number of concurrent threads that the InnoDB plug-in can create.

1464


write a program to print the consecutive repeated character from the given string... input string is : hhhhjkutskkkkkggggj output should be like this: hhhhkkkkkgggg anyone help me...

1477


What is a static function in c?

608


How to create struct variables?

576


Can two or more operators such as and be combined in a single line of program code?

794


Explain goto?

703


how many key words availabel in c a) 28 b) 31 c) 32

621


What is c system32 taskhostw exe?

572


Can you please explain the scope of static variables?

590