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

write a sorting prgm to sort 50 nos and sum them and also remove all the occurrences of 15 and print it?

2076


Why do we need arrays in c?

1080


List some applications of c programming language?

900


What is a pointer on a pointer in c programming language?

1091


What are logical errors and how does it differ from syntax errors?

1230


What does the function toupper() do?

1062


#include main() { enum _tag{ left=10, right, front=100, back}; printf("left is %d, right is %d, front is %d, back is %d",left,right,front,back); }

1065


Find the second largest element in an array with minimum no of comparisons and give the minimum no of comparisons needed on an array of size N to do the same.

1214


Hai sir, I had planned to write the NIC scientific engineer exam , plz post the sample question......

2136


What is the purpose of ftell?

1032


What is pointers in c?

1066


Explain how do you convert strings to numbers in c?

1019


Did c have any year 2000 problems?

1062


What is nested structure in c?

1011


What is ## preprocessor operator in c?

1024