Write a program to compare two strings without using the
strcmp() function
Answer Posted / bharat prajapati
#include <stdio.h>
#include <string.h>
main()
{
char s1[10],s2[10];
int i,j;
clrscr();
printf("\nEnter first String:");
scanf("%s",s1);
printf("\nEnter second String:");
scanf("%s",s2);
for(i=0;s1[i]!='\0';i++)
{
for(j=0;s2[j]!='\0';j++)
{
if(s1[i] == s2[j])
continue;
}
}
if (i==j)
{
printf("String s1 : %s and s2 : %s are EQUAL \n",s1,s2);
}
else
printf("String s1 : %s and s2 : %s are NOT EQUAL
\n",s1,s2);
getch();
}
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Is null equal to 0 in sql?
What is a union?
What are the functions to open and close the file in c language?
What does node * mean?
What is atoi and atof in c?
What is boolean in c?
application areas a 'c' a) operating system b) graphics, interpreter, assembler c) program evalution, communication softwares d) all the above
Why we use conio h in c?
Explain void pointer?
What is the difference between array and linked list in c?
int i=10; printf("%d %d %d", i, i=20, i);
Which control loop is recommended if you have to execute set of statements for fixed number of times?
How do we print only part of a string in c?
What are dangling pointers? How are dangling pointers different from memory leaks?
I was asked to write a program in c which when executed displays how many no.of clients are connected to the server.