Write a program to compare two strings without using the
strcmp() function
Answer Posted / abhishek
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<conio.h>
void main()
{
clrscr();
char a[100],b[100];
int i,m;
cout<<"enter first string";
gets(a);
cout<<"enter second string";
gets(b);
for(i=0;a[i]!='\0'&&b[i]!='\0';i++)
{
if(a[i]!=b[i])
{
c=1;
}
}
if(c==1)
{cout<<"the strings do not match!";
}
else
{
cout<<"the strings match!";
}
getch();
}
Is This Answer Correct ? | 7 Yes | 9 No |
Post New Answer View All Answers
Tell me is null always defined as 0(zero)?
Is there a way to compare two structure variables?
What is FIFO?
What is the main difference between calloc () and malloc ()?
Do you know pointer in c?
a c code by using memory allocation for add ,multiply of sprase matrixes
What are local variables c?
What are the ways to a null pointer can use in c programming language?
Difference between linking and loading?
Explain what are run-time errors?
main() { struct s1 { char *str; struct s1 *ptr; }; static struct s1 arr[] = { {"Hyderabad",arr+1}, {"Bangalore",arr+2}, {"Delhi",arr} }; struct s1 *p[3]; int i; < BR> for(i=0;i<=2;i++) p[i] = arr[i].ptr; printf("%s ",(*p)->str); printf("%s ",(++*p)->str); printf("%s ",((*p)++)->str); }
What are pointers in C? Give an example where to illustrate their significance.
What are the differences between new and malloc in C?
What is indirection?
Write the syntax and purpose of a switch statement in C.