Write a program to compare two strings without using the
strcmp() function
Answer Posted / shashi
#include<stdio.h>
#include<conio.h>
int stringcmp(char s1[], char s2[]);
int main()
{
char str1[10],str2[10];
printf("\nEnter first String:");
scanf("%s",str1);
printf("\nEnter second String:");
scanf("%s",str2);
if (stringcmp(str1,str2))
{
printf("String s1:%s and s2:%s are EQUAL\n",str1,str2);
}
else
printf("String s1:%s and s2:%s are NOT EQUAL\n",str1,str2);
getch();
return 0;
}
int stringcmp(char *s1, char *s2)
{
int flag=0;
char *count;
count=s1;
while(*count++)
{
flag=0;
if(*s1++==*s2++)
{
flag=1;
}
}
return flag;
}
| Is This Answer Correct ? | 4 Yes | 1 No |
Post New Answer View All Answers
What is pivot in c?
If I have a char * variable pointing to the name of a function ..
How can you determine the maximum value that a numeric variable can hold?
application attempts to perform an operation?
Create a structure to specify data on students given below: Roll number, Name, Department, Course, Year of joining Assume that there are not more than 450 students in the college. 1.write a function to print names of all students who joined in a particular year 2.write a function to print the data of a student whose roll number is given
What is preprocessor with example?
Is c is a procedural language?
What is difference between function overloading and operator overloading?
What are near, far and huge pointers?
Can a pointer be static?
What is the difference between typedef struct and struct?
what is the role you expect in software industry?
c language supports bitwise operations, why a) 'c' language is system oriented b) 'c' language is problem oriented c) 'c' language is middle level language d) all the above
What is queue in c?
What is a const pointer in c?