Write a program to compare two strings without using the
strcmp() function
Answer Posted / raj
#include<stdio.h>
void main()
{
char name[80],name1[80];
int i;
printf("enter 1st string");
gets(name);
printf("enter 2st string");
gets(name1);
i=0;
while(name[i]==name1[i] && name1[i]!='\0')
i++;
if(name[i]==name1[i])
printf("two strings r equal\n");
else
printf("two strings r not equal\n");
}
Is This Answer Correct ? | 4 Yes | 1 No |
Post New Answer View All Answers
Explain what are the different data types in c?
Differentiate between ordinary variable and pointer in c.
In c language can we compile a program without main() function?
What is a 'null pointer assignment' error? Explain what are bus errors, memory faults, and core dumps?
What are the types of type qualifiers in c?
Compare and contrast compilers from interpreters.
Can we use any name in place of argv and argc as command line arguments?
Can you define which header file to include at compile time?
Explain what are the standard predefined macros?
What happens if you free a pointer twice?
How can I swap two values without using a temporary?
What are nested functions in c?
I have written a pro*C program to fetch data from the cursor. where in i have used the concept of BULK FETCH.... each FETCH statement is taking lots of time to fetch specified number of rows at...
What is %g in c?
Can stdout be forced to print somewhere other than the screen?