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
Why is c so important?
How to set file pointer to beginning c?
given post order,in order construct the corresponding binary tree
to print the salary of an employee according to follwing calculation: Allowances:HRA-20% of BASIC,DA-45% of BASIC,TA-10%. Deductions:EPF-8% of BASIC,LIC-Rs.200/-Prof.Tax:Rs.200/- create c language program?
What is the advantage of an array over individual variables?
What is dynamic memory allocation?
in multiple branching construct "default" case is a) optional b) compulsarily c) it is not include in this construct d) none of the above
What are dangling pointers? How are dangling pointers different from memory leaks?
Should a function contain a return statement if it does not return a value?
What do you mean by recursion in c?
Explain a file operation in C with an example.
What is %d called in c?
What is the size of a union variable?
Why c is called object oriented language?
What is wrong with this program statement? void = 10;