Write a program to compare two strings without using the
strcmp() function
Answer Posted / allen
#include<stdio.h>
#include<conio.h>
void stringcmp(char s1[], char s2[]);
void main()
{
char str1[10],str2[10];
printf("\nEnter first String:");
scanf("%s",str1);
printf("\nEnter second String:");
scanf("%s",str2);
stringcmp(str1,str2);
}
void stringcmp(char *s1, char *s2)
{
int i,j,c=0;
for(i=0,j=0;s1[i]!='\0'||s2[j]!='\0';i++,j++)
{
if(s1[i]!=s2[j])
{
c++;
}
}
if(c==0)
printf("\nstring match");
else
printf("\nstring does not match");
}
Is This Answer Correct ? | 12 Yes | 4 No |
Post New Answer View All Answers
Stimulate calculator using Switch-case-default statement for two numbers
Explain about block scope in c?
Is return a keyword in c?
if (i = 0)printf ("True"); elseprintf("False"); Under what conditions will the above print out the string "True" a) Never b) Always c) When the value of i is 0 d) all of the above
What are the __date__ and __time__ preprocessor commands?
How was c created?
What are the complete rules for header file searching?
Is a house a shell structure?
What does sizeof int return?
What is quick sort in c?
What is difference between structure and union in c programming?
Describe dynamic data structure in c programming language?
Explain null pointer.
write a program that will open the file, count the number of occurences of each word in the the complete works of shakespeare. You will then tabulate this information in another file.
how to find binary of number?