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

int compare(char str2[], char str1[]) {
int flag = -1;
int i=0;
while(str1[i]!='\0' && str2[i]!='\0'){
if((str1[i]==str2[i])) {flag = 0;}
else if (str1[i]>str2[i]) {
flag=-1;
break;
}else if(str1[i]<str2[i]){
flag = 1;
break;
}
i++;
}

if(strlen(str1)==strlen(str2) && flag==0 ){
flag = 0;
}
else if(strlen(str1)>strlen(str2) && flag==0 ){
flag = 1;
}
else {flag = -1;}
return flag;
}

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain how can type-insensitive macros be created?

1042


What are the rules for the identifier?

1217


What are the 4 types of programming language?

1189


What does a function declared as pascal do differently?

1222


How do we open a binary file in Read/Write mode in C?

1278


What are 3 types of structures?

1103


What the different types of arrays in c?

1123


What is a void pointer in c?

1158


write a C program: To recognize date of any format even formats like "feb-02-2003","02-february-2003",mm/dd/yy, dd/mm/yy and display it as mm/dd/yy.

3868


What does the format %10.2 mean when included in a printf statement?

1708


What will the code below print when it is executed?   int x = 3, y = 4;         if (x = 4)                 y = 5;         else                 y = 2;         printf ("x=%d, y=%d ",x,y);

1944


What is a good data structure to use for storing lines of text?

1139


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

1135


Q.1 write a program to create binary tree 1 to 16 numbers? Q.2 write a program to creat a binary search tree for the member that is given by user?

2595


What does the && operator do in a program code?

1282