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

Answer Posted / dinesh

#include<stdio.h>
#include<conio.h>
void main()
{
char name1[20],name[20];
int i,j,c=0;
clrscr();
printf("enter two strings");
scanf("%s%s",name1,name);
for(i=0,j=0;name1[i]!='\0'||name[j]!='\0';i++,j++)
{
if(name1[i]!=name[j])
{
c++;
}
}
if(c==0)
printf("equal strings");
else
printf("not equal strings");
}

Is This Answer Correct ?    10 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What functions are used for dynamic memory allocation in c language?

868


What is difference between function overloading and operator overloading?

875


What is scanf_s in c?

854


what is ur strangth & weekness

2043


Why doesn't C support function overloading?

2178


can any one provide me the notes of data structure for ignou cs-62 paper

1915


Where we use clrscr in c?

912


#define PRINT(int) printf("int = %d ",int) main() {< BR> intx,y,z; x=03;y=02;z=01; PRINT(x^x); z<<=3;PRINT(x); y>>=3;PRINT(y); }

959


A function can make the value of a variable available to another by a) declaring the variable as global variable b) Passing the variable as a parameter to the second function c) Either of the two methods in (A) and (B) d) binary stream

932


Is c a great language, or what?

862


code for quick sort?

1825


What is the difference between far and near ?

935


What is difference between static and global variable in c?

779


What is the use of sizeof?

765


Explain the concept and use of type void.

876