Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

Answer Posted / md.ershad.ezaz

int strcompare(char *,char *);
void main()
{
char s1[15],s2[15];
int cmp;
clrscr();
puts("Enter first string");
gets(s1);
puts("Enter second string");
gets(s2);
cmp=strcompare(s1,s2);
if(cmp==0)
puts("strings are equal");
else
puts("strings are not equal");
getch();
}
int strcompare(char *p1,char *p2)
{
while(*p1==*p2)
{
if(*p1=='\0')
return(0);
p1++;
p2++;
}
return(*p1-*p2);
}

Is This Answer Correct ?    4 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Linked lists -- can you tell me how to check whether a linked list is circular?

1133


Explain what is a static function?

1157


What is a header file?

1135


What is break in c?

1102


what is a constant pointer in C

1245


List the different types of c tokens?

1120


Explain that why C is procedural?

1192


What are the storage classes in C?

1203


With the help of using classes, write a program to add two numbers.

1078


What is a node in c?

1023


What is dynamic dispatch in c++?

1108


What is a null string in c?

1103


How can you pass an array to a function by value?

1178


What does the error message "DGROUP exceeds 64K" mean?

1276


my project name is adulteration of chille powder.how can i explain it to the hr when he asks me about the project?

1644