Write a program to compare two strings without using the
strcmp() function

Answer Posted / sumant maurya

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char a[10];
char b[10];
int flag=0;
clrscr();
puts("enter the first string\n");
gets(a);
puts("enter the second string\n");
gets(b);
for(int i=0;i<=strlen(a);i++)
{
if(a[i]==b[i])
{
flag=1;
}
}
if(flag==1)
{
puts("matches");
}
else
{
puts("not matches");
}
getch();
}

Is This Answer Correct ?    6 Yes 8 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is main return c?

507


#define PRINT(int) printf("int = %d ",int) main() {< BR> intx,y,z; x=03;y=02;z=01; PRINT(x^x); z<<=3;PRINT(x); y>>=3;PRINT(y); }

709


How to write a multi-statement macro?

616


How many levels of indirection in pointers can you have in a single declaration?

587


In c programming typeing to occupy the variables in memory space. if not useing the variable the memory space is wasted.ok, how to avoid the situation..? (the variable is used & notused)

1623






What are comments and how do you insert it in a C program?

732


When should we use pointers in a c program?

618


What is typedef?

657


what are # pragma staments?

1619


How can a string be converted to a number?

506


Tell me what are bitwise shift operators?

648


In a switch statement, explain what will happen if a break statement is omitted?

619


What is the difference between c and python?

574


What is volatile c?

513


What are pointers in C? Give an example where to illustrate their significance.

738