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 / aiattack

#include <stdio.h>
#include <string.h>
int main()
{
char a[10];
char b[10];
int check = 0;
gets(a);
gets(b);
if (strlen(a)!=strlen(b)) {
printf("Strings don't match!");
} else {
for(int i=0, j=0; a[i] != '' || b[i] != ''; i++, j++) {
if(a[i] == b[i]) {
check = 0;
} else {
check ++;
break;
}
}
if (check == 0) printf("Strings match!");
else printf("Strings don't match");
}
return 0;
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How many header files are in c?

1064


Why do we use main function?

1234


How many bytes are occupied by near, far and huge pointers (dos)?

1216


What's the best way of making my program efficient?

1151


What is the code in while loop that returns the output of given code?

2069


What is the Purpose of 'extern' keyword in a function declaration?

1140


What are 3 types of structures?

1103


How variables are declared in c?

1099


If errno contains a nonzero number, is there an error?

1428


Array is an lvalue or not?

1186


What is getch?

1273


What is chain pointer in c?

1108


Whats s or c mean?

1083


What does 3 mean in texting?

1162


What is the translation phases used in c language?

1171