Write a program to compare two strings without using the
strcmp() function
Answer Posted / belsia
void main()
{
char a[10],b[10];
int i=0;
scanf("%s%s",a,b);
if(strlen(a)!=strlen(b))
printf("they are different strings");
else
{
while(a[i]!='\0')
{
if(a[i]==b[i])
i++;
else
{
printf("They are different strings");
exit(0);
}
printf("Both are same");
}
getch();
}
| Is This Answer Correct ? | 27 Yes | 16 No |
Post New Answer View All Answers
What are different types of pointers?
What are the preprocessor categories?
Who is the main contributor in designing the c language after dennis ritchie?
What is a #include preprocessor?
application areas a 'c' a) operating system b) graphics, interpreter, assembler c) program evalution, communication softwares d) all the above
main() { int i = 10; printf(" %d %d %d ", ++i, i++, ++i); }
How can I write a function that takes a format string and a variable number of arguments?
What is static memory allocation?
Can a pointer be volatile in c?
Write a function that will take in a phone number and output all possible alphabetical combinations
Why is extern used in c?
What is volatile variable how do you declare it?
Explain what is a 'null pointer assignment' error? Explain what are bus errors, memory faults, and core dumps?
What is a MAC Address?
cin.ignore(80, _ _);This statement a) ignores all input b) ignores the first 80 characters in the input c) ignores all input till end-of-line d) iteration