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


Please Help Members By Posting Answers For Below Questions

Explain what are the different data types in c?

741


Differentiate between ordinary variable and pointer in c.

605


In c language can we compile a program without main() function?

560


What is a 'null pointer assignment' error? Explain what are bus errors, memory faults, and core dumps?

716


What are the types of type qualifiers in c?

636






Compare and contrast compilers from interpreters.

669


Can we use any name in place of argv and argc as command line arguments?

593


Can you define which header file to include at compile time?

571


Explain what are the standard predefined macros?

636


What happens if you free a pointer twice?

594


How can I swap two values without using a temporary?

599


What are nested functions in c?

551


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...

9642


What is %g in c?

602


Can stdout be forced to print somewhere other than the screen?

603