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

Answer Posted / raghu

#include<stdio.h>
#include<conio.h>
void main()
{
char a[100],b[100];
int i,c;
clrscr();
printf("enter first string");
scanf("%s",&a);
printf("enter second string");
scanf("%s",&b);
for(i=0;a[i]!='\0'&&b[i]!='\0';i++)
{
if(a[i]!=b[i])
{
c=1;
}
}
if(c==1)
{
printf("the strings do not match!");
}
else
{
printf("the strings match!");
}
getch();
}

Is This Answer Correct ?    8 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can you write the function prototype, definition and mention the other requirements.

647


a c code by using memory allocation for add ,multiply of sprase matrixes

2290


What is preprocessor with example?

572


code for find determinent of amatrix

1505


How to write a program for machine which is connected with server for that server automatically wants to catch the time for user of that machine?

1578






What is this infamous null pointer, anyway?

600


How do you determine a file’s attributes?

589


What is keyword in c?

586


What is an array? What the different types of arrays in c?

647


What are structures and unions? State differencves between them.

605


What is #ifdef ? What is its application?

638


A routine usually part of the operation system that loads a program into memory prior to execution a) linker b) loader c) preprocessor d) compiler

614


Which is better between malloc and calloc?

658


What are the storage classes in C?

616


What are the types of c language?

543