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
Where does the name "C" come from, anyway?
What is integer constants?
What is spaghetti programming?
What is variable declaration and definition in c?
Difference between goto, long jmp() and setjmp()?
How do you determine a file’s attributes?
What is the maximum no. of arguments that can be given in a command line in C.?
What are the salient features of c languages?
Wt are the Buses in C Language
What are the key features in c programming language?
Why is c called "mother" language?
Why c is called object oriented language?
Do you know null pointer?
illustrate the use of address operator and dereferencing operator with the help of a program guys plzzz help for this question
What is volatile, register definition in C