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
Which is better oop or procedural?
program to find out date after adding 31 days to a date in the month of febraury also consider the leap year
Explain can the sizeof operator be used to tell the size of an array passed to a function?
What is the symbol indicated the c-preprocessor?
what does static variable mean?
What is the modulus operator?
What is the explanation for modular programming?
What is a MAC Address?
Explain what is the benefit of using const for declaring constants?
What is the -> in c?
What is the size of array float a(10)?
why to assign a pointer to null sometimes??how can a pointer we declare get assigned with a garbage value by default???
Explain setjmp()?
Simplify the program segment if X = B then C ← true else C ← false
Write a program to generate the Fibinocci Series