Write a program to compare two strings without using the
strcmp() function
Answer Posted / belsia
void main()
{
char a[10],b[10];
int i=0;
scanf("%s%s",a,b);
if(strlen(a)!=strlen(b))
printf("they are different strings");
else
{
while(a[i]!='\0')
{
if(a[i]==b[i])
i++;
else
{
printf("They are different strings");
exit(0);
}
printf("Both are same");
}
getch();
}
Is This Answer Correct ? | 27 Yes | 16 No |
Post New Answer View All Answers
Is it better to use malloc() or calloc()?
What is meant by errors and debugging?
.main() { char *p = "hello world!"; p[0] = 'H'; printf("%s",p); }
program for reversing a selected line word by word when multiple lines are given without using strrev
How can I trap or ignore keyboard interrupts like control-c?
What is the importance of c in your views?
Tell me with an example the self-referential structure?
What is the scope of static variable in c?
Is c++ based on c?
Explain can the sizeof operator be used to tell the size of an array passed to a function?
What are the rules for identifiers in c?
What library is sizeof in c?
Why use int main instead of void main?
any "C" function by default returns an a) int value b) float value c) char value d) a & b
What is meant by preprocessor in c?