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 / ria varughese

#include <stdio.h>
#include <string.h>

void stringcmp(char s1[], char s2[]);

int main()
{

char str1[10],str2[10];

printf("\nEnter first String:");
scanf("%s",str1);

printf("\nEnter second String:");
scanf("%s",str2);

stringcmp(str1,str2);

return 0;
}

void stringcmp(char *s1, char *s2)
{
int i,j;

for(i=0;s1[i]!='\0';i++)
{
for(j=0;s2[j]!='\0';j++)
{
if(s1[i] == s2[j])
continue;
}
}

if (i==j)
{
printf("String s1:%s and s2:%s are EQUAL\n",s1,s2);
}
else
printf("String s1:%s and s2:%s are NOT EQUAL\n",s1,s2);

}

Is This Answer Correct ?    84 Yes 89 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Where are the auto variables stored?

1090


What extern c means?

931


How can you read a directory in a C program?

1095


What are the scope of static variables?

1117


Why does everyone say not to use scanf? What should I use instead?

1367


Program to find the sum of digits of a given number until the sum becomes a single digit. (e.g. 12345=>1+2+3+4+5=15=>1+5=6)

1099


What do you mean by dynamic memory allocation in c? What functions are used?

1107


What is the difference between char array and char pointer?

982


How is a macro different from a function?

1118


Explain the process of converting a Tree into a Binary Tree.

2608


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

983


What are c identifiers?

1039


What is quick sort in c?

1021


How many types of arrays are there in c?

996


What is the difference between single charater constant and string constant?

1031