Write a program to compare two strings without using the
strcmp() function
Answer Posted / waqar nawaz
#include<iostream.h>
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int c=0;
char a[10];
char b[10];
gets(a);
gets(b);
for(int i=0,j=0;b[i]!='\0'||a[j]!='\0';i++,j++)
{
if(a[i]!=b[j])
{
c++;
}
}
if(c==0)
cout<<"string match";
else
cout<<"string does not match";
getch();
}
| Is This Answer Correct ? | 104 Yes | 51 No |
Post New Answer View All Answers
When can you use a pointer with a function?
Explain how can you restore a redirected standard stream?
What is the use of printf() and scanf() functions?
What is the difference between null pointer and wild pointer?
What is graph in c?
What is a far pointer in c?
What are lookup tables in c?
How many parameters should a function have?
What is pragma c?
What is the modulus operator?
any C program contains only one function, it must be a) void () b) main () c) message () d) abc ()
Explain what is the most efficient way to store flag values?
what is ur strangth & weekness
Where does the name "C" come from, anyway?
Write a program to generate the Fibinocci Series